ramontricolor12

LISTA 03 - Exercício 15

Jun 15th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 03 - Exercicio 15.c
  3.    Objetivo: Descubra o numero sorteado atraves de algumas tentativas.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <time.h>
  10. int main()
  11. {
  12.     int numeroAlvo, numeroUsuario, cont = 0, saida = 0;
  13.  
  14.     srand(time(NULL));
  15.     numeroAlvo = rand() % 100;
  16.     printf("\n******DESCUBRA O NUMERO******\n");
  17.     do
  18.     {
  19.         printf("\nDigite um numero de 1 a 100: ");
  20.         scanf("%d", &numeroUsuario);
  21.  
  22.         if(numeroUsuario > numeroAlvo)
  23.             printf("\nTente um numero menor.");
  24.         else if(numeroUsuario < numeroAlvo)
  25.             printf("\nTente um numero maior.");
  26.         else
  27.         {
  28.             printf("\nParabens, voce conseguiu!!!");
  29.             saida = -1;
  30.         }
  31.         cont++;
  32.     }while(saida != -1);
  33.  
  34.     if(cont == 1)
  35.         printf("\nOTIMO! Voce alcancou a facanha com apenas 1 tentativa!!!\n");
  36.     else if(cont < 7)
  37.         printf("\nBOM! Voce alcancou a facanha com apenas %d tentativas!!!\n",cont);
  38.     else if(cont < 15)
  39.         printf("\nREGULAR! Voce alcancou o numero com %d tentativas!!!\n",cont);
  40.     else
  41.         printf("\nPRECISA MELHORAR! Voce alcancou o numero com %d tentativas!!!\n",cont);
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment