/*
** EPITECH PROJECT, 2026
** rush1-3.c
** File description:
** bleh
*/
#include <unistd.h>
void my_putchar(char c)
{
write(1, &c, 1);
}
static int print_corner(int x, int y, int i, int j)
{
if (i == 0 && j == 0) {
my_putchar('A');
return 1;
}
if (i == 0 && j == x - 1) {
my_putchar('C');
return 1;
}
if (i == y - 1 && j == 0) {
my_putchar('C');
return 1;
}
if (i == y - 1 && j == x - 1) {
my_putchar('A');
return 1;
}
return 0;
}
static void print_char(int x, int y, int i, int j)
{
if (x == 1 || y == 1) {
my_putchar('B');
return;
}
if (print_corner(x, y, i, j))
return;
if (i == 0 || i == y - 1 || j == 0 || j == x - 1) {
my_putchar('B');
} else {
my_putchar(' ');
}
}
void rush(int x, int y)
{
if (x <= 0 || y <= 0) {
write(2, "Invalid size\n", 13);
return;
}
for (int i = 0; i < y; i++) {
for (int j = 0; j < x; j++) {
print_char(x, y, i, j);
}
my_putchar('\n');
}
}
int main()
{
rush(4, 4);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: