aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Brattlof <hello@bryanbrattlof.com>2020-08-06 12:07:36 -0400
committerBryan Brattlof <hello@bryanbrattlof.com>2020-08-06 13:43:10 -0400
commitb1981a81cc7cd08b343131dbb9386454a0a7d040 (patch)
treee2a89a82fa2070dbb80c8ce12d37ec42ad93eedb
parent8642edf29ef6eff5077d76ce2e6d4ee2bda4a979 (diff)
downloadsudoku-b1981a81cc7cd08b343131dbb9386454a0a7d040.tar.gz
sudoku-b1981a81cc7cd08b343131dbb9386454a0a7d040.tar.bz2
c: add function to display puzzles in a 9x9 grid
-rw-r--r--c/main.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/c/main.c b/c/main.c
index b435194..cdc9e6b 100644
--- a/c/main.c
+++ b/c/main.c
@@ -1,8 +1,34 @@
#include <stdio.h>
+
+void display(char puzzle[])
+{
+ printf("\n ");
+
+ int i = 0;
+ while(puzzle[i] != '\0') {
+ printf(" %d", puzzle[i] - '0');
+
+ if(i % 9 == 8)
+ printf("\n ");
+ i++;
+ }
+
+ printf("\n");
+}
+
+
+char* solve(char puzzle[])
+{
+ display(puzzle);
+}
+
+
int main(int argc, char *argv[])
{
for(int i=1; i < argc; i++) {
printf("Puzzle No.%d: %s\n", i, argv[i]);
+ solve(argv[i]);
}
+ return 0;
}