+ 1
I've written code for the Spy Life Code Coach. It works perfectly but the test cases come back wrong even though outputs match
#include <iostream> using namespace std; string words,ans; int main() { getline(cin,words); int len=words.length(); for(int i=0;i<len;i++) { if (isalpha(words[i]) || words[i]==' ') { ans+=words[i]; } } //cout<<ans; int lans=ans.length(); string output=""; for (int i=0; i<lans+1; i++) {output+=ans[lans-i];} cout<<output; return 0; } *Why does it not work?*
2 Respostas
+ 2
Ah thanks I forgot the lans--;
+ 1
I tried the -1. No difference. I can see my output is identical to expected output. For some reason it's still staying red though and not computing as correct...