Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4.  
  5. int compare (const void * a, const void * b) {
  6. return ( *(int*)a - *(int*)b );
  7. }
  8.  
  9. int main(int argc, char* argsv[]) {
  10.  
  11. srand (time(NULL));
  12.  
  13. // teams dices declare
  14. int team_red[3];
  15. int team_yellow[3];
  16.  
  17. // roll dices!
  18. int i = 0;
  19. for(; i < 3; i ++) {
  20. team_red[i] = rand() % 6 + 1;
  21. team_yellow[i] = rand() % 6 + 1;
  22. }
  23.  
  24. printf("Dices team Red: %i, %i, %i \n", team_red[0], team_red[1], team_red[2]);
  25. printf("Dices team Yellow: %i, %i, %i \n\n", team_yellow[0], team_yellow[1], team_yellow[2]);
  26.  
  27. qsort (team_red, 3, sizeof(int), compare);
  28. qsort (team_yellow, 3, sizeof(int), compare);
  29.  
  30. printf("Dices team Red ordered: %i, %i, %i \n", team_red[0], team_red[1], team_red[2]);
  31. printf("Dices team Yellow oredered: %i, %i, %i \n", team_yellow[0], team_yellow[1], team_yellow[2]);
  32.  
  33. int red_points = 0;
  34. int yellow_points = 0;
  35.  
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement