gotta fix

This commit is contained in:
aryan 2024-05-04 00:08:11 -06:00
parent 7155aa5a6e
commit 75865e768b
3 changed files with 91 additions and 0 deletions

BIN
lab-3/a.out Executable file

Binary file not shown.

85
lab-3/main.c Normal file
View file

@ -0,0 +1,85 @@
#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");
}
}

6
lab-3/tmp1 Normal file
View file

@ -0,0 +1,6 @@
$
$$
$$$
$$$$
$$$$$
$$$$$$