Reverse the strings by words
Reverse the strings by words
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char str[500];
char strn[50][50];
cout<<"Enter the string: ";
cin.getline(str,500);
int len = strlen(str);
for(int x=0;str[x]!='\0';x++)
{
for(int i = 0; str[x]==' ';i++)
{
strn[i][i] = str[x] ;
break;
}
}
cout<<strn[0];
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char str[500];
char strn[50][50];
cout<<"Enter the string: ";
cin.getline(str,500);
int len = strlen(str);
for(int x=0;str[x]!='\0';x++)
{
for(int i = 0; str[x]==' ';i++)
{
strn[i][i] = str[x] ;
break;
}
}
cout<<strn[0];
return 0;
}
No comments: