|
http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=33096 [복사]
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
srand(time(NULL));
int ran = rand()%11+1;
int in;
real:
printf("Input a number (0~10) : ");
scanf("%d",&in);
if(in > 10){
printf("\nPlease input a number between 0 and 10.\n");
goto real;}
if(in < 0){
printf("\nPlease input a number between 0 and 10.\n");
goto real;}
if(in == ran){
printf("\nWow~ that's my favorite number!");
return 0;}
else{
printf("\nYour wrong. I don't like that number.\n");
printf("input again.\n");
goto real;}
}
0부터 10까지 수 중에 하나를 맞추는 건데요..
해보니깐 수십번 해야 한번 맞추던데
코드가 이상한건가요 아님 그냥 우연인건가요? |
Hit : 10241 Date : 2015/01/14 12:06
|