rush012.c

This commit is contained in:
Timo Schmidt 2023-03-19 02:24:50 +01:00
parent 263ffbc114
commit 2ea1890e40
1 changed files with 49 additions and 0 deletions

49
rush02.c Normal file
View File

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush02.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/18 20:15:12 by jtorrez- #+# #+# */
/* Updated: 2023/03/19 02:23:41 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
#include "include/ft_putchar.h"
#include "include/ft_lib.h"
#include "include/rush0X.h"
const char g_inside = ' ';
// corners specified clockwise, starting from top left
const char g_corners[] = {'A', 'A', 'C', 'C', '\0'};
const char g_horizontal = 'B';
const char g_vertical = 'B';
void rush(int x, int y)
{
int i;
i = 0;
if (x * y == 0)
return ;
horiz_line(g_corners[0], g_horizontal, g_corners[1], x);
while (i++ < y - 2)
horiz_line(g_vertical, g_inside, g_vertical, x);
if (y > 1)
horiz_line(g_corners[3], g_horizontal, g_corners[2], x);
}
void horiz_line(char left, char middle, char right, int width)
{
int i;
i = 0;
ft_putchar(left);
while (i++ < width - 2)
ft_putchar(middle);
if (width > 1)
ft_putchar(right);
ft_putchar('\n');
}