#include <stdio.h>
void ft_putchar(char c)
{
putchar(c);
}
void rush(int x, int y)
{
int index_x;
int index_y;
index_y = 0;
while (index_y < y) // tant que index_y est inférieur à y, j'écris une ligne
{
index_x = 0; // index_x est égal à 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) // si je suis au tout début de ma première ligne
ft_putchar('o');
else if (index_x == x - 1 && index_y == 0) // sinon si je suis à la fin de ma première ligne
ft_putchar('o');
else if (index_x == 0 && index_y == y - 1) // sinon si je suis au tout début de ma dernière ligne
ft_putchar('o');
else if (index_x == x - 1 && index_y == y - 1) // sinon si je suis à la fin de ma dernière ligne
ft_putchar('o');
else if (index_y == 0 || index_y == y - 1) // sinon si je suis à ma première ou dernière ligne
ft_putchar('-');
else if (index_x == 0 || index_x == x - 1) // sinon si je suis au tout début ou à la fin de ma ligne
ft_putchar('|');
else // sinon, j'affiche un espace
ft_putchar(' ');
index_x++; // j'augmente index_x de 1
}
ft_putchar('\n'); // je suis arrivé à la fin de ma ligne, donc j'affiche le caractère '\n'
index_y++; // j'augmente index_y de 1
}
}
int main()
{
rush(5, -1); // exemple d'appel à la fonction rush
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: