72 lines
1.6 KiB
C
72 lines
1.6 KiB
C
#include <stdio.h>
|
|
|
|
// Function prototypes
|
|
void print_block(int n, int m); // Print the pattern
|
|
// n: columns
|
|
// m: rows
|
|
void print_row(int n, int m); // Print a line of row, called bu print_block
|
|
// n: number of columns m: position of row
|
|
// n: number of columns, see print_column
|
|
// m: ranging from 0 to 3
|
|
// m == 0: |*****|*****|*****|
|
|
// m == 1: | | | | | | |
|
|
// m == 2: |--+--|--+--|--+--|
|
|
// m == 3: | | | | | | |
|
|
void print_column(int n,
|
|
int m); // Print a single character, called by print_row
|
|
// n: type of char in a single line
|
|
// m: type of char in multiple lines
|
|
// m == 0: |***** n is defined by the position in the line with particular m
|
|
// m == 1: | |
|
|
// m == 2: |--+--
|
|
// m == 3: | |
|
|
|
|
int main(void) {
|
|
// Initialize variables and read input
|
|
int row, col;
|
|
scanf("%d", &row);
|
|
scanf("%d", &col);
|
|
|
|
// The magic starts here
|
|
print_block(col, row);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void print_block(int n, int m) {
|
|
for (int i = 0; i < m * 4; i++) {
|
|
print_row(n, i % 4);
|
|
}
|
|
print_row(n, 0); // The last line
|
|
}
|
|
|
|
void print_row(int n, int m) {
|
|
for (int i = 0; i < n * 6; i++) {
|
|
print_column(i % 6, m);
|
|
}
|
|
print_column(0, m); // The last char
|
|
printf("\n");
|
|
}
|
|
|
|
void print_column(int n, int m) {
|
|
if (n == 0) {
|
|
printf("|");
|
|
} else if (n == 1 || n == 2 || n == 4 || n == 5) {
|
|
if (m == 0) {
|
|
printf("*");
|
|
} else if (m == 2) {
|
|
printf("-");
|
|
} else {
|
|
printf(" ");
|
|
}
|
|
} else if (n == 3) {
|
|
if (m == 0) {
|
|
printf("*");
|
|
} else if (m == 2) {
|
|
printf("+");
|
|
} else {
|
|
printf("|");
|
|
}
|
|
}
|
|
}
|