IvoSilva

[PROG1] Ficha 8 | Exercício 3

Dec 5th, 2011
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. int main ()
  3. {
  4.     int i , j , num ;
  5.     float v[6] ;
  6.     srand (time(NULL)) ;
  7.     for (i = 0 ; i < 30 ; i++)
  8.     {
  9.         num = rand() % 6 + 1 ;
  10.         v[num - 1]++ ;
  11.     }
  12.     printf ("Histograma de 30 lançamentos :\n") ;
  13.     for (i = 0 ; i < 6 ; i++)
  14.     {
  15.         printf ("%d - " , i + 1) ;
  16.         for (j = 0 ; j < v[i] ; j++) printf ("*") ;
  17.         printf ("\n") ;
  18.     }
  19.     printf ("\n") ;
  20.     return 0 ;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment