MUstar

IoT C언어 0419 - 도전실전1_1

Apr 19th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7.     int i, sc;
  8.     int rm;
  9.     srand(time(NULL));
  10.     rm=rand()%30;
  11.    
  12.     printf("컴퓨터가 생각하는 숫자 = %d\n",rm); //Temp Code
  13.     start:
  14.         printf("숫자입력(1부터 30까지) : ");
  15.         scanf("%d",&sc);
  16.         if(sc==rm){printf("정답입니다!\n"); i++; goto last;}
  17.         else if(sc>rm){printf("%d보다 작습니다!\n",sc); i++; goto start;}
  18.         else if(sc<rm){printf("%d보다 큽니다!\n",sc); i++; goto start;}
  19.         else {printf("error"); goto end;}
  20.  
  21.     last:
  22.         printf("시도한 횟수는 %d회 입니다.\n",i);
  23.        
  24.     end:
  25.         return 0;
  26. }
Add Comment
Please, Sign In to add comment