#include<bits/stdc++.h>
using namespace std;
int main(){
char str[10000];
string s[20];
cout<<"Please enter the string\n";
gets(str);
strrev(str);
int cnt1=0,cnt2=0;
for(int i=0;i<strlen(str);i++){
if(str[i+1]=='\0'){
for(int j=i;j>=cnt1;j--){
cout<<str[j];
}
cout<<"\n";
}
if(str[i]==' '){
for(int j=i-1;j>=cnt1;j--){
cout<<str[j];
}
cout<<" ";
cnt1=i+1;
}
}
return 0;
}
using namespace std;
int main(){
char str[10000];
string s[20];
cout<<"Please enter the string\n";
gets(str);
strrev(str);
int cnt1=0,cnt2=0;
for(int i=0;i<strlen(str);i++){
if(str[i+1]=='\0'){
for(int j=i;j>=cnt1;j--){
cout<<str[j];
}
cout<<"\n";
}
if(str[i]==' '){
for(int j=i-1;j>=cnt1;j--){
cout<<str[j];
}
cout<<" ";
cnt1=i+1;
}
}
return 0;
}
No comments:
Post a Comment