-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmx_cube.c
More file actions
executable file
·28 lines (25 loc) · 809 Bytes
/
mx_cube.c
File metadata and controls
executable file
·28 lines (25 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <unistd.h>
#include <stdlib.h>
void print(char *c, int d[]){
for (int i = 0; c[i]; i++)
for (int j = 0; j < d[i]; j++)
write(1, c[i], 1);
}
void mx_cube(int n){
if (n < 2)
return;
print(" +-+\n", (int []){((n / 2) + 1), 1, 2 * n, 1, 1});
for (int i = n / 2; i > 0; i--)
print(" / / |\n", (int []){i, 1, 2 * n, 1, n / 2 - i, 1, 1});
print("+-+ |\n", (int []){1, 2 * n, 1, n / 2, 1, 1});
for(int i = 0; i < (n - 1) / 2; i++)
print("| | |\n", (int []){1, 2 * n, 1, n / 2, 1, 1});
print("| | +\n", (int []){1, 2 * n, 1, n / 2, 1, 1});
for(int i = 0; i < n / 2; i++)
print("| | /\n", (int []){1, 2 * n, 1, (n / 2 - i - 1), 1, 1});
print("+-+\n", (int []){1, 2 * n, 1, 1});
}
int main(int argc, char *argv[]){
mx_cube(atoi(argv[argc - 1]));
return 0;
}