nikolas_serafini

Lista 3 - Exercício 49

Jun 16th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. int main()
  5. {
  6.     int i,number,times,token,occurrence = 0;
  7.    
  8.     srand(time(NULL));
  9.  
  10.     printf("Entre com um numero de 1 a 100 :\n");
  11.     scanf("%d",&number);
  12.     printf("Entre com a quantidade de sorteios :\n");
  13.     scanf("%d",&times);
  14.  
  15.     for (i = 0; i < times; i++)
  16.     {
  17.         token = rand() % 100 + 1;
  18.         if (number == token)
  19.         {
  20.             occurrence++;
  21.         }
  22.         printf("%d\n",token);
  23.     }
  24.  
  25.     printf("\nNumero inserido apareceu %d vezes no sorteio!\n",occurrence);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment