these 2 functions are linked with each other. #define MAX_BOARD_SIZE 12 // Players #define PLAYER_EMPTY 0 #define PLAYER_BLACK 1 #define PLAYER_WHITE 2 int board_size; int current_player = PLAYER_BLACK; char board[MAX_BOARD_SIZE][MAX_BOARD_SIZE]; int main(void); void announce_winner(void); unsigned int count_discs(int player); void announce_winner(void) { int black_count = count_discs(PLAYER_BLACK); int white_count = count_discs(PLAYER_WHITE); if (white_count > black_count) { printf("The game is a win for WHITE!\n"); white_count += count_discs(PLAYER_EMP

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Question

convert c code to mips

these 2 functions are linked with each other.

#define MAX_BOARD_SIZE 12

// Players

#define PLAYER_EMPTY 0

#define PLAYER_BLACK 1

#define PLAYER_WHITE 2

int board_size;

int current_player = PLAYER_BLACK;

char board[MAX_BOARD_SIZE][MAX_BOARD_SIZE];

int main(void);

void announce_winner(void);

unsigned int count_discs(int player);

void announce_winner(void) {

int black_count = count_discs(PLAYER_BLACK);

int white_count = count_discs(PLAYER_WHITE);

 

if (white_count > black_count) {

printf("The game is a win for WHITE!\n");

white_count += count_discs(PLAYER_EMPTY);

} else if (black_count > white_count) {

printf("The game is a win for BLACK!\n");

black_count += count_discs(PLAYER_EMPTY);

} else {

printf("The game is a tie! Wow!\n");

}

 

printf("Score for black: %d, for white: %d.\n", black_count, white_count);

}

unsigned int count_discs(int player) {

int count = 0;

for (int row = 0; row < board_size; ++row) {

for (int col = 0; col < board_size; ++col) {

if (board[row][col] == player) {

count++;

}

}

}

return count;

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT