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
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;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)