int main(int argc, char *argv[]) { int dice, roll; int sides; char sets; printf("Enter the number of sets; enter q to stop.\n"); while(scanf("%d", &sets)) { int *res; res = (int *)malloc(sets * sizeof(int)); srand((unsigned int)time(0)); printf("How many sides and how many dice?\n"); scanf("%d", &sides); scanf("%d", &dice); printf("Here are %d sets of %d %d-sided throws:\n", sets, dice, sides); for (int i = 0; i < (int)sets; i++) { res[i] = roll_n_dice(dice, sides); printf("%d ", res[i]); } printf("\n"); free(res); printf("Enter the number of sets; enter q to stop.\n"); } }
int main (void) { int dice, roll; int sides; srand ((unsigned int) time (0)); printf ("Enter the number of sides per die, 0 to stop.\n"); while (scanf ("%d", &sides) == 1 && sides > 0) { puts ("How many dice?\n"); scanf ("%d", &dice); roll = roll_n_dice (dice, sides); printf ("You have rolled a %d using %d %d-sided dice.\n", roll, dice, sides); puts ("How many sides? Enter 0 to stop. \n"); } printf ("The rollem () function was called %d times.\n", roll_count); printf ("GOOD FORTUNE TO YOU !\n"); return 0; }