ramontricolor12

LISTA 03 - Exercício 16

Jun 28th, 2013
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 03 - Exercicio 16.c
  3.    Objetivo: Exiba uma lista com 40 grupos(cada grupo possui 3 numeros em ordem crescente) de numeros sorteados de 0 a 59 .
  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 i, j, geradorNum, num1 = 0, num2 = 0, num3 = 0;
  13.  
  14.     srand(time(NULL));
  15.  
  16.     for(i = 1; i <= 40; i++)
  17.     {
  18.         for(j = 1; j <= 3; j++)
  19.         {
  20.             geradorNum = rand() % 60;
  21.             if(geradorNum >= num1)
  22.                 num1 = geradorNum;
  23.             else if(geradorNum >= num2)
  24.                 num2 = geradorNum;
  25.             else if(geradorNum >= num3)
  26.                 num3 = geradorNum;
  27.         }
  28.         printf(">>> %d %d %d \n", num3, num2, num1);
  29.     }
  30.     return 0;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment