int sweet(int l,int n,int m )
{
if(m==0)
return l;
if(l>=n)
return sweet(1,n,m-1);
else
return sweet(l+1,n,m-1);
}
int display(int d)
{
if(d==0)
return 0;
else
{
int n,m,s;
scanf("%d %d %d",&n,&m,&s);
printf("%d\n",sweet(s-1,n,m));
return display(d-1);}
}
int main()
{
int t;
scanf("%d",&t);
display(t);
}
Asked
Active
Viewed 150 times
-3

Adrian Mole
- 49,934
- 160
- 51
- 83

Arindom Bora
- 1
- 1
-
1It is not clear what your problem is and the provided code is unreadable. – user5329483 Apr 18 '20 at 14:17
1 Answers
0
Timeout error appears to be related to the scanf. If you look at the man page, scanf takes input from standard in. If the specific digits are not present in stdin, the program will hang as scanf will continue waiting for what it's looking for to appear.

Cheetaiean
- 901
- 1
- 12
- 26