0
Cheer Creator Problem
I'm trying to solve the cheer creator problem in C language, but I'm still having 2 out of 5 test cases failing, and I have absolutely no idea what's wrong. Can anyone kindly check my code and point out the error? Thanks so much. https://www.sololearn.com/coach/20?ref=app
6 Respostas
+ 4
The loop is executed even if one of the if-statements before has already been triggered for all inputs other than zero, which should really not be the case.
+ 1
I've solved it guys.
Thanks Shadow and Thống Nguyễn
0
Here's my code
#include <stdio.h>
int main() {
int yard;
int j;
scanf("%d", &yard);
j=yard;
if(j < 1)
{
printf("shh");
}
if(j > 10)
{
printf("High Five");
}
while(j=yard)
{
if(j>0 && j<11)
{
printf("Ra!");
yard--;
j--;
}
}
return 0;
}
0
Jim Ezesinachi first: you need to put the final if() out side the while()(or the while()'s stament always run): like this: if(){while(){}}
Second: wrap your condition like this: while((j...))
0
Thanks guys.
Lemme get to work
0
Please to help you!