[C Language] i don't know what's wrong with my code? Help me, please.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[C Language] i don't know what's wrong with my code? Help me, please..

The question and my code in the link. https://code.sololearn.com/cpsUlFZAwcT6/?ref=app https://code.sololearn.com/c3UA3Rt0y94w/?ref=app

13th Jan 2021, 5:58 AM
Briana
Briana - avatar
11 Answers
+ 3
Can I get the link to the original question ? ( just to make sure it isn't a part of any ongoing competition)
13th Jan 2021, 6:18 AM
Arsenic
Arsenic - avatar
+ 3
Briana delete only the extra int declarations. Leave flag = 0 and flag = 1 there (without the int). Also clean up the characters before flag = 0.
13th Jan 2021, 10:11 AM
Brian
Brian - avatar
+ 3
Briana Test case 2 works, as well. Yay! There are warnings about unused variables p and r declared in line 5.
13th Jan 2021, 10:19 AM
Brian
Brian - avatar
+ 1
Arsenic i don't know how to share. It's in microsoft word
13th Jan 2021, 6:20 AM
Briana
Briana - avatar
+ 1
Lines 44 and 47 redefine flag as a local variable. Remove the int declarations, because it is already defined. Also, in line 44 there is a spurious invisible character 302 between int and flag. Delete all characters on the line before flag. After these fixes it appears to give correct output at least for the first test case. I did not try the second one.
13th Jan 2021, 9:57 AM
Brian
Brian - avatar
+ 1
Brian i know.. I already remove other output.. But i don't know why it's keep say run error
13th Jan 2021, 10:39 AM
Briana
Briana - avatar
0
Brian but, if I delete the flag, the 'yes' or 'no' appears m times. My code also keep give the output NO, even though it's YES
13th Jan 2021, 10:10 AM
Briana
Briana - avatar
0
Brian it's work in my compiler.. But i don't know why the online judge say it's run error
13th Jan 2021, 10:32 AM
Briana
Briana - avatar
0
Maybe it is expecting only YES or NO. The other outputs might be counted as wrong.
13th Jan 2021, 10:37 AM
Brian
Brian - avatar
0
Briana I suspect the arrays h[100], s[100], u[100], and v[100] need to be larger. If N can be 100, my calculation says M can be as high as 4950, which requires those arrays to be that large, too.
13th Jan 2021, 11:08 AM
Brian
Brian - avatar
0
Briana please also fix line 8. It needs correction to the upper limit check for m. (Needs m<=)
13th Jan 2021, 11:32 AM
Brian
Brian - avatar