#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
while(1){
printf("=========UP and Down ======= \n");
printf("숫자는 1~100 사이의 수 \n");
printf("기회는 6번 화이팅 \n\n");
srand(time(NULL));
int com=rand()%((100-1)+1)+1;
char ans=NULL;
int tn=6;
for(tn; tn>0; tn--){
char ch;
int num;
printf("com 의 숫자 : %d \n",com);
printf("input number : ");
scanf("%d",&num);
scanf("%c",&ch);
fflush(stdin);
if((num>100 || num <1) && ch==10){
printf("1~100 사이의 수를 입력하세요 \n");
printf("%d 번 남았습니다 \n\n", tn-1);
}else if((num==com) && ch==10){
printf("정답! 축하해요 \n\n");
return 0;
}else if((num>com) && ch==10){
printf("다운 \n");
printf("%d 번 남았습니다 \n\n", tn-1);
}else if((num<com) && ch==10){
printf("업 \n");
printf("%d 번 남았습니다 \n\n", tn-1);
}
if(ch!=10){
printf("숫자를 입력하세요 \n");
printf("%d 번 남았습니다 \n\n", tn-1);
}
} //for
int res;
while(1){
printf("retry? y/n ");
scanf("%c", &ans);
fflush(stdin);
if(ans=='y'){
printf("\n\n");
res=1;
break;
}else if(ans=='n'){
res=0;
break;
}else{
printf("다시 입력하세요\n\n");
continue;
}
} //while
if(res==1)
continue;
else if(res==0)
break;
} //while
return 0;
} //main
'C / C++' 카테고리의 다른 글
structure and typedef which make new type of definition (0) | 2014.08.13 |
---|---|
structure (0) | 2014.08.12 |
coding a basic program (0) | 2014.08.01 |
functions that can make some random numbers with the headers (0) | 2014.07.31 |
multiple if, while sentences and some other grammars (0) | 2014.07.30 |