#include <iostream>
#include<cstring>
using namespace std;
void reverseStringWordWise(char input[]) {
// Write your code here
int sp = strlen(input);
int o_size = sp;
char output[sp];
int p = sp;
int j = sp-1;
int i=0;
while(j>=0 || j==-1) // Since the first word will not have any space before it So it wont count
{
if(input[j]==' ' ||j==-1)
{
for(int k = j+1; k<p;k++) // j gets iterated from -1 to 0. Thus giving the frist word upto the the last space traced.
{
output[i++] = input[k];
}
p = j;
j--;
output[i++] = ' ';
}
else
{
j--;
}
}
for(int l=0;l<sp;l++)
{
input[l] = output[l];
}
}
int main() {
char input[1000];
cin.getline(input, 1000);
reverseStringWordWise(input);
cout << input << endl;
}
Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.
Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.
👥 Ideal for solo developers, teams, and cross-company projects
Top comments (0)