Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define nfacce 6
- int lanci (int, int);
- int main ()
- {
- int n, nlanci, i, j, k, X;
- printf ("Inserire il numero di dadi da lanciare \n");
- scanf ("%d", &n);
- printf ("Inserire il numero di lanci da effettuare \n");
- scanf ("%d", &nlanci);
- srand(time(0));
- for (i = 1; i <= nlanci; i++)
- {
- k = lanci(nfacce,n);
- printf ("%d %d \n", i, k);
- k = 0;
- }
- }
- int lanci (int Nfacce, int N)
- {
- int x, I, contaocc = 0;
- for (I = 1; I <= N; I++)
- {
- x = rand()%Nfacce + 1;
- if (x == 3)
- contaocc++;
- }
- return contaocc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement