I was tasked with creating a program that uses an array to simulate between 1 and 100k six sided dice rolls. I have to declare an array inside main which holds the dice rolls, and use code to simulate the actual rolls outside of main. My main issue is not understanding the basics of arrays, how to sort the numbers that will be returned, and how to use srand to simulate dice rolls. I will attach what code I have so far, it's very poorly written, far from finished, and definitely incorrect. I am hoping some of you could explain some of the fundamentals behind my misunderstandings so that I can better teach myself, I am NOT asking for anyone to do any work for me. Thanks in advance for any help!
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void Randomize(){
srand(time(NULL)) ;
}
void DiceSort(int a[], int roll) {
for (int j = 6; j < roll-2; j++) {
for (int i = 0; i < roll-1; i++){
if (a[i] > a[i+1]) {
int temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
}
}
}
}
void printArray(int a[], int roll){
for (int i = 0; i < roll; i++){
printf("%d ", a[i]);
}
printf("\n");
}
int main(){
printf("Ryan Braden\n CS102-02\n Programming Assignment #3\nThis program will simulate between one and one hundred thousand six-sided dice rolls and print out the results.\n");
unsigned int diceroll[100000]={};
system ("pause");
}
Aucun commentaire:
Enregistrer un commentaire