Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int diceThrow, throwCount, tmp, i, j, tcc, throws[], array[], throwtot, avrageRoll;
- int DiceRoll(){
- diceThrow = srand(5) + 1;
- return diceThrow;}
- int SortRolls(throws){
- array[] = throws[];
- for (i = 0; i < throwCount - 1; ++i)
- for (j = throwCount - 1; j < i; --j)
- if (array[j-1] > array[j]) {
- tmp = array[j-1];
- array[j-1] = array[j];
- array[j] = tmp;}}
- int main(){
- printf("How many times shall I throw the dice? : ");
- scanf("%d", &throwCount);
- tcc = throwCount;
- while (tcc > 0){
- int newrolls = DiceRoll();
- throws[] << newrolls;
- throwtot = throwtot + newrolls;
- tcc--1;}
- avrageRoll = throwtot / throwCount;
- return 0;
- }
Add Comment
Please, Sign In to add comment