+ 5
The Spy Life. Why test do not check
#include <iostream> using namespace std; int main() { const int A = 65, Z = 90, a = 97, z = 122, space = 32; string str, res; getline(cin, str); for (unsigned long int i = 0; i < str.length(); i++){ if (((str[i] >= A) && (str[i] <= Z)) || ((str[i] >= a) && (str[i] <= z)) || (str[i] == space)){ res += str[i]; } } int k = 0; for (unsigned long int i = res.length() + 1; i > 0;){ cout<<res[--i]; } return 0; }
4 Antworten
+ 1
Use res.length(), instead of res.length()+1 & Try again....
And why need unsigned long int? int is enough..
+ 1
The program gives the expected answer, but the test fails.
+ 1
Jayakrishna, thank you
0
Imperator Teney you're welcome..