ソースを参照

Trying solve triangle patten

2much 2 年 前
コミット
40e5e40ca9
共有1 個のファイルを変更した17 個の追加0 個の削除を含む
  1. 17 0
      tannebaumv3.c

+ 17 - 0
tannebaumv3.c

@@ -1,14 +1,18 @@
 #include <stdio.h>
  
 #define GRID_SIZE 9
+#define GRID_MIDDLE GRID_SIZE/2
   
 void initGrid(char grid[][GRID_SIZE]);
 void printGrid(char grid[][GRID_SIZE]);
+void makeTree(char grid[][GRID_SIZE]);
  
 int main(void) {
     char grid[GRID_SIZE][GRID_SIZE];
+    char symbol = '*';
  
     initGrid(grid);
+    makeTree(grid);
     printGrid(grid);
  
     return 0;
@@ -28,3 +32,16 @@ void printGrid(char grid[][GRID_SIZE]) {
         printf("\n");
     }
 }
+
+void makeTree(char grid[][GRID_SIZE]) {
+
+    for (int x = 0; x < GRID_SIZE; x++ ) {
+	for (int y = 0; y < GRID_SIZE; y++) {
+            grid[x][y] = ' ';
+        }
+        for (int y = 0; y < x/2; y++) {
+	    grid[y][x] = '^';
+	    grid[x][y] = '*';
+        }
+    }
+}