+ 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?*

26th May 2020, 10:06 AM
Olivia
Olivia - avatar
4 Respuestas
+ 2
Ah thanks I forgot the lans--;
26th May 2020, 10:38 AM
Olivia
Olivia - avatar
+ 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...
26th May 2020, 10:29 AM
Olivia
Olivia - avatar