Advertisement
Guest User

Würfeln

a guest
Dec 15th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<time.h>
  4. #define SIZE 7
  5.  
  6.  
  7. int main(void)
  8. {
  9. int face;
  10. int a;
  11. int roll;
  12.  
  13. int frequency[SIZE]={0};
  14.  
  15. srand(time(NULL));
  16.  
  17. for(roll=1;roll<=20;roll++){
  18. if(rand()%6==0){
  19. face=6;
  20. ++frequency[face];
  21. }
  22. else{
  23. face=rand()%6;
  24. ++frequency[face];
  25. }
  26.  
  27. }
  28.  
  29.  
  30. printf("%s%17s%18s\n","Face","Frequency","Histogram");
  31.  
  32. for(face=1;face<SIZE; face++){
  33. printf("%4d%17d ",face,frequency[face]);
  34. for(a=1;a<=frequency[face];a++){
  35. printf("%c",'*');
  36. }
  37. printf("\n");
  38. }
  39. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement