forked from akemi/c-labs
86 lines
1.7 KiB
C
86 lines
1.7 KiB
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
//prototypes idk why we need these but we had to use them in 220 uwu
|
||
|
void Square(int hwidth);
|
||
|
void Triangle(int hwidth);
|
||
|
void ITriangle(int hwidth);
|
||
|
void Diamond(int hwidth);
|
||
|
|
||
|
int main(int argc, char **argv) {
|
||
|
if (argc != 3) {
|
||
|
printf("erm thats wrong silly, shape then max width\n");
|
||
|
}
|
||
|
|
||
|
int shape = atoi(argv[1]);
|
||
|
int hwidth = atoi(argv[2]);
|
||
|
|
||
|
if (shape == 1) {
|
||
|
Square(hwidth);
|
||
|
} else if (shape == 2) {
|
||
|
Triangle(hwidth);
|
||
|
} else if (shape == 3) {
|
||
|
ITriangle(hwidth);
|
||
|
} else if (shape == 4) {
|
||
|
Diamond(hwidth);
|
||
|
} else {
|
||
|
printf("wrong shape silly goose");
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void Square(int hwidth) {
|
||
|
int i, j;
|
||
|
for (i = 0; i < hwidth; i++) {
|
||
|
for (j = 0; j < hwidth; j++) {
|
||
|
printf("$");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Triangle(int hwidth) {
|
||
|
int i, j;
|
||
|
for (i = 0; i < hwidth; i++) {
|
||
|
for (j = 0; j <= i; j++) {
|
||
|
printf("$");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void ITriangle(int hwidth) {
|
||
|
int i, j;
|
||
|
for (i = hwidth - 1; i >= 0; i--) {
|
||
|
for (j = 0; j <= i; j++) {
|
||
|
printf("$");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Diamond(int hwidth) {
|
||
|
int i, j, space;
|
||
|
for (i = 1; i <= hwidth; i += 2) {
|
||
|
for (space = 0; space < (hwidth - i) / 2; space++) {
|
||
|
printf(" ");
|
||
|
}
|
||
|
for (j = 0; j < i; j++) {
|
||
|
printf("$");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
for (i = hwidth - 2; i >= 1; i -= 2) {
|
||
|
for (space = 0; space < (hwidth - i) / 2; space++) {
|
||
|
printf(" ");
|
||
|
}
|
||
|
for (j = 0; j < i; j++) {
|
||
|
printf("$");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|