Advertisement
ordepruhtra

jogo adiviha

Sep 3rd, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main (){
  5.     int n, chute, pontos, tent=0;
  6.     n=42;
  7.     pontos=1000;
  8.     while(1){
  9.         scanf("%i", &chute);
  10.         if(chute<0){
  11.             printf("apenas numeros positivos");
  12.             continue;
  13.         }
  14.         tent++;
  15.         else if(chute<n){
  16.             printf("Voce inserio um nรบmero menor\n");
  17.             pontos+=(chute-n)/2;
  18.             continue;
  19.         }
  20.         else if(chute>n){
  21.             printf("Voce inserio um nรบmero maior\n");
  22.             pontos-=(chute-n)/2;
  23.             continue;
  24.         }
  25.         else if(chute == n){
  26.             break;
  27.         }
  28.     }
  29.     printf("Voce acertou!\npontos = %i \ntentativas = %i\n", pontos, tent);
  30.  
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement