aboutsummaryrefslogtreecommitdiff
path: root/console/voerbak.c
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-02-13 11:31:42 +0100
committerlonkaars <l.leblansch@gmail.com>2021-02-13 11:31:42 +0100
commitdf5909c22a771851ba73a42975f42fab9c7541af (patch)
treeb1ca7c06a3eb2079405b1546fc4bc4f3bb52eb78 /console/voerbak.c
parent8ed583afc05901c17f3226421988758119dacd65 (diff)
v2 -> voerbak in c
Diffstat (limited to 'console/voerbak.c')
-rw-r--r--console/voerbak.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/console/voerbak.c b/console/voerbak.c
new file mode 100644
index 0000000..4eeabc5
--- /dev/null
+++ b/console/voerbak.c
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <memory.h>
+
+#define DISC_A "\x1b[31mo\x1b[39m"
+#define DISC_B "\x1b[34mo\x1b[39m"
+#define EMPTY "\x1b[90m_\x1b[39m"
+
+void printBoard(int board[], int width, int height) {
+ for (int y = height - 1; y > -1; y--) {
+ for (int x = 0; x < width; x++) {
+ int val = board[x + y * width];
+ char *print =
+ val == 0 ? EMPTY :
+ val == 1 ? DISC_A :
+ val == 2 ? DISC_B :
+ EMPTY;
+ printf("%s ", print);
+ }
+ printf("\n");
+ }
+}
+
+int main() {
+ int width, height;
+ scanf("%d %d", &width, &height);
+
+ int board[width * height];
+ memset(board, 0, sizeof board);
+
+ board[2] = 1;
+ board[3] = 2;
+ printBoard(board, width, height);
+
+ return 0;
+}