#include <unistd.h>

void	ft_putchar(char c)
{
	write(1, &c, 1);
}

// Fonction pour afficher une ligne
void	print_line(int x, int y, int index_y)
{
	int index_x = 0;

	while (index_x < x) // tant que index_x est inférieur à x, j'écris un caractère
	{
		if (index_x == 0 && index_y == 0) 
			ft_putchar('A');
		else if (index_x == x - 1 && index_y == 0) 
			ft_putchar('C');
		else if (index_x == 0 && index_y == y - 1) 
			ft_putchar('C');
		else if (index_x == x - 1 && index_y == y - 1) 
			ft_putchar('A');
		else if (index_y == 0 || index_y == y - 1) 
			ft_putchar('B');
		else if (index_x == 0 || index_x == x - 1) 
			ft_putchar('B');
		else 
			ft_putchar(' ');
		index_x++; 
	}
	ft_putchar('\n'); // je suis arrivé à la fin de ma ligne, donc j'affiche le caractère '\n'
}

// Fonction pour afficher l'ensemble du rectangle
void	rush(int x, int y)
{
	int index_y = 0;

	while (index_y < y) // tant que index_y est inférieur à y
	{
		print_line(x, y, index_y); // j'appelle print_line pour afficher une ligne
		index_y++; // j'augmente index_y de 1
	}
}

int main()
{
	rush(5, 3); // exemple d'appel à la fonction rush
	return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: