+ 1

The spy life || won't pass test 4

Don't know why it only fails test4. Can someone help me figure out what I am missing? #include <iostream> #include <string> using namespace std; int main(){ string code; string sol; getline(cin,code); int n=0; int s = code.length (); for(int i=0;i<code.size();i++){ if((code[i]>=97&&code[i]<=122)||code[i]==32||(code[i]>=65&&code[i]<=90)){ sol[n]=code[i]; n++; }else{s--;} } for(int i=s-1;i>=0;i--){ cout<<sol[i];} return 0; }

7th Sep 2020, 10:04 AM
Matteo Marinari
Matteo Marinari - avatar
1 Antwort
0
In sol[n] = code[i] use sol += code [i] instead.
7th Sep 2020, 11:54 AM
你知道規則,我也是
你知道規則,我也是 - avatar