CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Created by Swapnil More
/*
The code modifies the string in such a way that
their order remains same but the word itself is reversed.
Example:
Input==> This is a Sololearn Challenge
Output==> sihT si a nraeloloS egnellahC
*/
//Challenge thread is in the comments section
#include <iostream>
using namespace std;
int main() {
int i,j,k,m;
string arr;
std::string text;
*(getline(std::cin,text).tie());
cout<<"Enter something: ";
cout<<text<<endl;
m=text.length();
for(i=0,j=0;i<=m;i++){
if(text[i]==' '|| text[i]=='\0'){
for(k=0;j<=i;k++,j++){
arr[m-i+k]=text[j];
}
}
}
arr[k-1]=' ';
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run