From 643e13dee3367beacf4d6b822dc8fe10136a24f6 Mon Sep 17 00:00:00 2001 From: Daniel M Date: Thu, 8 Feb 2024 09:52:08 +0100 Subject: [PATCH] showMinefild --- src/main/duellist-spielesammlung-projekt.c | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/main/duellist-spielesammlung-projekt.c b/src/main/duellist-spielesammlung-projekt.c index cc6f212..9ff0743 100644 --- a/src/main/duellist-spielesammlung-projekt.c +++ b/src/main/duellist-spielesammlung-projekt.c @@ -179,6 +179,41 @@ void distribute_mines(char** mines, int height, int width, int num_mines) { } } +void show_minefield(char** minefield, int height, int width) { + int i, j; + + printf("\n\n"); + printf(" "); + for (i = 0; i < height; i++) { + printf("%3d", i + 1); + } + printf("\n"); + + printf(" "); + for (i = 0; i < width; i++) { + printf("---"); + } + printf("\n"); + + for (i = 0; i < height; i++) { + printf("%3d|", i + 1); + for (j = 0; j < width; j++) { + printf("%3c", minefield[i][j]); + } + printf(" |%-3d\n", i + 1); + } + printf(" "); + for (i = 0; i < width; i++) { + printf("---"); + } + printf("\n"); + printf(" "); + for (i = 0; i < width; i++) { + printf("%3d", i + 1); + } + printf("\n\n"); +} + int minesweeper() { int height, width, row, column; printf("Enter the height of the game field:\n");