Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- int compare (const void * a, const void * b) {
- return ( *(int*)a - *(int*)b );
- }
- int main(int argc, char* argsv[]) {
- srand (time(NULL));
- // teams dices declare
- int team_red[3];
- int team_yellow[3];
- // roll dices!
- int i = 0;
- for(; i < 3; i ++) {
- team_red[i] = rand() % 6 + 1;
- team_yellow[i] = rand() % 6 + 1;
- }
- printf("Dices team Red: %i, %i, %i \n", team_red[0], team_red[1], team_red[2]);
- printf("Dices team Yellow: %i, %i, %i \n\n", team_yellow[0], team_yellow[1], team_yellow[2]);
- qsort (team_red, 3, sizeof(int), compare);
- qsort (team_yellow, 3, sizeof(int), compare);
- printf("Dices team Red ordered: %i, %i, %i \n", team_red[0], team_red[1], team_red[2]);
- printf("Dices team Yellow oredered: %i, %i, %i \n", team_yellow[0], team_yellow[1], team_yellow[2]);
- int red_points = 0;
- int yellow_points = 0;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement