#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
int random, manu_num, num;
int count=0, min=999;
srand(time(NULL));
rand();rand();rand();rand();
srand(rand());
while(1){
printf("== Up & Down Game ==\n\n");
printf("1. Game Start\n2. Game Score\n3. End Game\n\n>");
scanf("%d",&manu_num);
switch(manu_num){
case 1:
count=0;
random=rand()%100+1; //랜덤값(1-100)
printf("정답 : %d\n",random); //정답확인
printf("<< Game Start >>\n");
while(1){
printf("Input Number(1~100) : ");
scanf("%d", &num);
count++;
if(num>=1 && num <=100){
if(num<random){
printf("숫자 %d 보다 << U P >>\n",num);
continue;
}
if(num>random){
printf("숫자 %d 보다 << D O W N >>\n",num);
continue;
}
if(num==random){
printf("YOU WIN!!\n정답은 %d 입니다.\n",num);
}
if(min>count)
min=count;
break;
}
else{
printf("1-00까지 숫자 입력하세요!!\n");
}
}
case 2:
printf("You Best Score : %d\n\n\n\n",min);
break;
case 3:
printf("게임을 종료합니다\n");
exit(0);
break;
default:
printf("잘못 눌렀습니다\n");
}
}
return 0;
}
댓글 없음:
댓글 쓰기