I am trying to make hexagons. I have a form, but I am doing something wrong while printing. A.
Here is my code and what I tried:
#include <stdio.h> int main() { int i, x; for (i = 1; i <= 2; i++) { for (x = 1; x <= 2; x++) { printf(" %d,%d\t \n", i, x); printf(" / \t \\\n"); printf("| \t |\n"); printf("| \t |\n"); printf(" \\ \t /\n"); } printf("\n\n"); } }
I need them horizontal, not vertical.
I know what I did wrong, that prints the hexadecimal form "m, n + 1" below the hexagon "m, n", and not on its right side.
But I do not know how to fix it. Thanks!
Fixed!
Update: Now Results
#include <stdio.h> #define COLS 4 #define ROWS 3 void subrow(char* pcWhat, char* pcEndWhat) { int col; for (col = 0; col < COLS; col++) { printf("%s", pcWhat); } printf("%s\n", pcEndWhat); } void indexedSubrow(char* pcWhat, char* pcEndWhat, int row, int offset) { int col; for (col = 0; col < COLS; col++) { printf(pcWhat, row, col+offset); } printf("%s\n", pcEndWhat); } int main(void) { int i, x; subrow(" ___ ",""); for (i = 0; i < ROWS; i++) { if(i==0){ subrow(" / \\ "," "); indexedSubrow("/ %d,%d \\___"," ", i, 0); subrow("\\ / ","\\"); indexedSubrow(" \\___/ %d,%d"," \\", i, 1); } //else if(i==ROWS-1){} else{ subrow(" / \\ "," /"); indexedSubrow("/ %d,%d \\___","/", i, 0); subrow("\\ / ","\\"); indexedSubrow(" \\___/ %d,%d"," \\", i, 1); } } return 0; }
More explanations and art of what I need:
The last subrow is: \ / \ / \ / \ / \ \___/ 2,1 \___/ 2,3 \___/ 2,5 \___/ 2,7 \ Which should be \ / \ / \ / \ / \ \___/ 2,1 \___/ 2,3 \___/ 2,5 \___/ 2,7 \ \ / \ / \ / \ / \___/ \___/ \___/ \___/ So the missing part is: \ / \ / \ / \ / \___/ \___/ \___/ \___/
I'm also interested in how to add numbers ("Let them say 1 as the second digit in all hex grids") Example:
Current art:
___ ___ ___ ___ / \ / \ / \ / \ / 0,0 \___/ 0,1 \___/ 0,2 \___/ 0,3 \___ \ / \ / \ / \ / \ \___/ 0,1 \___/ 0,2 \___/ 0,3 \___/ 0,4 \ / \ / \ / \ / \ / / 1,0 \___/ 1,1 \___/ 1,2 \___/ 1,3 \___/ \ / \ / \ / \ / \ \___/ 1,1 \___/ 1,2 \___/ 1,3 \___/ 1,4 \ / \ / \ / \ / \ / / 2,0 \___/ 2,1 \___/ 2,2 \___/ 2,3 \___/ \ / \ / \ / \ / \ \___/ 2,1 \___/ 2,2 \___/ 2,3 \___/ 2,4 \
Expectation: (overall as an end result)
___ ___ ___ ___ / \ / \ / \ / \ / 0,0 \___/ 0,2 \___/ 0,4 \___/ 0,6 \___ \ 1 / \ 1 / \ 1 / \ 1 / \ \___/ 0,1 \___/ 0,3 \___/ 0,5 \___/ 0,7 \ / \ 1 / \ 1 / \ 1 / \ 1 / / 1,0 \___/ 1,2 \___/ 1,4 \___/ 1,6 \___/ \ 1 / \ 1 / \ 1 / \ 1 / \ \___/ 1,1 \___/ 1,3 \___/ 1,5 \___/ 1,7 \ / \ 1 / \ 1 / \ 1 / \ 1 / / 2,0 \___/ 2,2 \___/ 2,4 \___/ 2,6 \___/ \ 1 / \ 1 / \ 1 / \ 1 / \ \___/ 2,1 \___/ 2,3 \___/ 2,5 \___/ 2,7 \ \ 1 / \ 1 / \ 1 / \ 1 / \___/ \___/ \___/ \___/
Thanks!