Symbols cod coach (fails case #4 & case #5) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Symbols cod coach (fails case #4 & case #5)

it passes all the others but I dont know what the problem is i thought it was for the output and it has to be a string instead of char array but it was not the problem https://code.sololearn.com/cuea1tofah3I/#cpp #include <iostream> #include <string> using namespace std; int main () { string input ; int j =0 ; char temp[30]; getline (cin, input); for (int i = 0 ; input[i] ; i++ ){ if ((input[i]>='a'&&input[i]<='x')||(input[i]>='A'&& input[i]<='Z')||(input[i]==' ')||(input[i]>'0'&& input[i]<'9')){ temp[j++]=input[i]; } } string s ; temp [j+1]='\0'; for (int k = 0;k<j;k++) {s=s+temp[k];} cout<< s ; return 0 ; }

9th Aug 2021, 11:57 AM
Arman Tahery
Arman Tahery - avatar
7 Answers
+ 2
#include <iostream> #include <string> #include <ctype.h> using namespace std; int main() { string s; getline(cin,s); for(unsigned i=0;i<s.length();i++){ if(isalpha(s[i]) || isdigit(s[i]) || isspace(s[i])){ cout<<s[i]; } else{ continue; } } return 0; } This is a simpler approach and easy for anyone to understand. I Don't know what is the problem with your code between.
9th Aug 2021, 12:31 PM
HK Lite
HK Lite - avatar
+ 2
these are secret cases so i dont know more than you
9th Aug 2021, 6:55 PM
Arman Tahery
Arman Tahery - avatar
+ 1
You should add more information about the failure of your test
9th Aug 2021, 12:19 PM
Rautnich Sassi Federico
Rautnich Sassi Federico - avatar
+ 1
Could you put the text of this case? :)
9th Aug 2021, 6:57 PM
Rautnich Sassi Federico
Rautnich Sassi Federico - avatar
+ 1
I mean, what is the object of your case? What would you do with this code?
9th Aug 2021, 7:11 PM
Rautnich Sassi Federico
Rautnich Sassi Federico - avatar
0
it's hidden
9th Aug 2021, 6:59 PM
Arman Tahery
Arman Tahery - avatar
0
It's challenge in code coach if you have mobile app of solo learn you can have access to these
9th Aug 2021, 7:26 PM
Arman Tahery
Arman Tahery - avatar