online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
//задача состоит в том, чтобы выдать 4-ым игрокам по 6 карт. Проверить, есть ли комбинация полтина(4 карты одинаковой масти идущих подряд. например 2,3,4,5 пик) в руке каждого игрока #include <stdio.h> #include <stdlib.h> #include <time.h> #include <locale.h> #define N_suits 4 #define N_ranks 13 #define Number_of_cards_in_hand 6 #define Number_of_players 4 #define t 10 #define j 11 #define q 12 #define k 13 #define a 14 void Sort(int mas, int array_size) { //int mas[N_suits][N_ranks]; for (int i = 0; i < Number_of_cards_in_hand; i++) { int min = i; for (int p = i+1; p < Number_of_cards_in_hand; p++) { if (mas[p][1] < mas[min][1]) { min = p; } } if (min != i) { int tmp[2] = { mas[i][0], mas[i][1] }; mas[i][0] = mas[min][0]; mas[i][1] = mas[min][1]; mas[min][0] = tmp[0]; mas[min][1] = tmp[1]; } } } int Check(int *mas[]) { for (int i = 0; i < Number_of_cards_in_hand; i++) { int c = 0; if ((mas[N_suits][i] < mas[N_suits][i + 1]) && (mas[i][N_ranks] == mas[i + 1][N_ranks])) c++; else return 0; return c; } } int main() { int played[N_suits][N_ranks] = { 0 }; //общий пул карт int in_hand[N_suits][N_ranks]; //массив карт в руке одного игрока int rank, suit; int Number = Number_of_cards_in_hand; const char rank_code[] = { '2', '3', '4', '5', '6', '7', '8', '9', 't', 'j', 'q', 'k','a' }; const char suit_code[] = {'h', 'd', 'c', 's'}; srand(time(0)); printf("game settings:\nnumber of players - %i\nnumber of cards in hand - %i\n\n", Number_of_players, Number_of_cards_in_hand); for (int i = 1; i <= Number_of_players; i++) { printf("hand of %i player: ", i); int counter = 0; int tmp = 0; while (Number > 0) { suit = rand() % N_suits; rank = rand() % N_ranks; if (!played[suit][rank]) { played[suit][rank] = 1; in_hand[suit][rank] = 1; Number--; printf(" %c%c", rank_code[rank], suit_code[suit]); if (suit == tmp) counter++; tmp = suit; } } printf("\n"); Number = Number_of_cards_in_hand; if (counter >= 4) { Sort(in_hand[N_suits][N_ranks], Number_of_cards_in_hand); Check(in_hand[N_suits][N_ranks]); } in_hand[suit][rank] = { 0 }; } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue