Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #define nfacce 6
  5.  
  6. int lanci (int, int);
  7. int main ()
  8. {
  9. int n, nlanci, i, j, k, X;
  10. printf ("Inserire il numero di dadi da lanciare \n");
  11. scanf ("%d", &n);
  12. printf ("Inserire il numero di lanci da effettuare \n");
  13. scanf ("%d", &nlanci);
  14. srand(time(0));
  15. for (i = 1; i <= nlanci; i++)
  16. {
  17. k = lanci(nfacce,n);
  18. printf ("%d %d \n", i, k);
  19. k = 0;
  20. }
  21. }
  22.  
  23. int lanci (int Nfacce, int N)
  24. {
  25. int x, I, contaocc = 0;
  26. for (I = 1; I <= N; I++)
  27. {
  28. x = rand()%Nfacce + 1;
  29. if (x == 3)
  30. contaocc++;
  31. }
  32. return contaocc;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement