int main()
{
int value,count;
char ans,replay;
int min, max;
min = 0;
replay = 'n';
do
{
printf("큰 수 하나를 입력하세요");
scanf("%d",&max);
printf("%d 부터 %d 사이의 수를 생각하세요\n", min, max);
ans = 'N';
srand(time(NULL));
count=0;
while(ans!='y' && ans!='Y')
{
value = rand()%(max - min);
printf("당신이 생각한 숫자가 %d 입니까?", value);
scanf("%c", &ans);
count++;
}
printf("%d 번 만에 맞추었지요!", count);
printf("다시 하시겠습니까?");
scanf("%c",&replay);
}while(replay=='y' || replay=='Y');
return 0;
}
이랬는데
"당신이 생각한 숫자가 %d 입니까?"
를 한번 물어보는게 아니라 두번씩 물어보네요..-ㅁ-)
왜그럴까요?
ffush를 이용해 보시거나 scanf 대신 getchar 나 fget 같은걸 사용해보세요