Guest User

Untitled

a guest
May 26th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int diceThrow, throwCount, tmp, i, j, tcc, throws[], array[], throwtot, avrageRoll;
  5.  
  6. int DiceRoll(){
  7. diceThrow = srand(5) + 1;
  8. return diceThrow;}
  9.  
  10. int SortRolls(throws){
  11. array[] = throws[];
  12. for (i = 0; i < throwCount - 1; ++i)
  13. for (j = throwCount - 1; j < i; --j)
  14. if (array[j-1] > array[j]) {
  15. tmp = array[j-1];
  16. array[j-1] = array[j];
  17. array[j] = tmp;}}
  18.  
  19. int main(){
  20. printf("How many times shall I throw the dice? : ");
  21. scanf("%d", &throwCount);
  22. tcc = throwCount;
  23.  
  24. while (tcc > 0){
  25. int newrolls = DiceRoll();
  26. throws[] << newrolls;
  27. throwtot = throwtot + newrolls;
  28. tcc--1;}
  29.  
  30. avrageRoll = throwtot / throwCount;
  31.  
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment