2014. 8. 11. 15:21
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#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





Posted by af334