0
Why for "The Spy Life" this code doesn't work with ASCII code :
#include <iostream> #include <string> using namespace std; int main() { string s; cin>>s; int n; n=s.size(); for(int i=n-1;i>=0;i--){ if((s[i]<91 && s[i]>64) || (s[i]>96 && s[i]<123) || s[i]==' '){ cout<<s[i]; } } return 0; }
1 Odpowiedź
+ 1
cin>>s; by this, cin accept only single word. You need read entire line of string contains more words also..
Use getline method...
getline(cin, s);