+ 4

[Solved by Fernando Pozzetti] Code coach YT link finder has expected output but failed.

My .C code failed in every test case but the output seems just like expected output. #include <stdio.h> int main() { char a[42]={0}; int c=32,b=17; for(int I=0;I<=42;I++){ scanf("%c",&a[I]); } if(a[31]!=0){ for(int i=0;i<=11;i++){ printf("%c",a[c]); c++; } }if(a[31]==0){ for(int j=0;j<=11;j++){ printf("%c",a[b]); b++; } } return 0; }

27th Feb 2020, 4:09 AM
高于鈞
高于鈞 - avatar
7 odpowiedzi
+ 2
I see, I have just tried it. Could it be that the line break char is screwing it up?
27th Feb 2020, 4:26 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
+ 3
Fernando Pozzetti Oh... Thanks. I changed i and j to 10 and it's work. #include <stdio.h> int main() { char a[42]={0}; int c=32,b=17; for(int I=0;I<=42;I++){ scanf("%c",&a[I]); } if(a[31]!=0){ for(int i=0;i<=10;i++){ printf("%c",a[c]); c++; } }if(a[31]==0){ for(int j=0;j<=10;j++){ printf("%c",a[b]); b++; } } return 0; }
27th Feb 2020, 4:33 AM
高于鈞
高于鈞 - avatar
+ 2
Try with a bigger char size. 99 will be enough. Also, there are 2 types of links, so you will need to handle each one separately.
27th Feb 2020, 4:17 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
+ 2
Fernando Pozzetti What you mean
27th Feb 2020, 4:31 AM
高于鈞
高于鈞 - avatar
+ 1
Fernando Pozzetti Yes, I do think the 2 type of link in my code. It already solved, but my problem is the output just look like it's expected output but failed. If you'd like you can run this code in your playground to help me fix the code.
27th Feb 2020, 4:21 AM
高于鈞
高于鈞 - avatar
27th Feb 2020, 4:25 AM
高于鈞
高于鈞 - avatar
+ 1
Glad to help you
27th Feb 2020, 4:34 AM
Fernando Pozzetti
Fernando Pozzetti - avatar