uva problem no:10530

All about problems in Volume CV. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

uva problem no:10530

Postby snape » Mon Dec 26, 2011 3:51 pm

getting WA. plz help :(


#include <stdio.h>
#include <string.h>


long int right,high=8888,low=0,i=0,pre_high,pre_low,h=0;
char status[20],hg[1000],lw[1000];

int main()
{
int guess_num;
while(1)
{
if(guess_num==0)
break;

scanf("%d",&guess_num);
getchar();
gets(status);

if(strcmp(status,"too high")==0)
{
high=guess_num;
pre_high=high;
if(high<pre_low)
{
h=1;
}


}
else if(strcmp(status,"too low")==0)
{
low=guess_num;
pre_low=low;
if(low>pre_low)
{h=1;
}
}
else if(strcmp(status,"right on")==0)
{
right=guess_num;
if(h==1)
goto P;
if((high>right) && (low<right))
printf("Stan may be honest\n");
else
{P:
printf("Stan is dishonest\n");}

}


}


return 0;

}
snape
New poster
 
Posts: 5
Joined: Sat Dec 03, 2011 4:18 pm

Re: uva problem no:10530

Postby brianfry713 » Wed Jan 11, 2012 9:54 pm

Code: Select all
int guess_num;
while(1)
{
if(guess_num==0)
break;


This section of your code causes the program to exit before reading or printing anything.
brianfry713
Guru
 
Posts: 1755
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA


Return to Volume CV

Who is online

Users browsing this forum: No registered users and 1 guest