Solution
This commit is contained in:
commit
055739ffaf
|
@ -0,0 +1,18 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putchar.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/03/18 02:10:16 by tischmid #+# #+# */
|
||||||
|
/* Updated: 2023/03/18 02:10:20 by tischmid ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void ft_putchar(char c)
|
||||||
|
{
|
||||||
|
write(1, &c, 1);
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* main.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/03/18 02:09:32 by tischmid #+# #+# */
|
||||||
|
/* Updated: 2023/03/18 02:51:40 by tischmid ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
void rush(int x, int y);
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
rush(5, 3);
|
||||||
|
rush(5, 1);
|
||||||
|
rush(1, 1);
|
||||||
|
rush(1, 5);
|
||||||
|
rush(4, 4);
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* rush00.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/03/18 02:10:24 by tischmid #+# #+# */
|
||||||
|
/* Updated: 2023/03/18 03:02:19 by tischmid ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
void ft_putchar(char c);
|
||||||
|
void horiz_line(char left, char middle, char right, int width);
|
||||||
|
|
||||||
|
const char g_inside = ' ';
|
||||||
|
|
||||||
|
// Rush 00
|
||||||
|
// clockwise, starting from top left
|
||||||
|
// const char g_corners[] = {'o', 'o', 'o', 'o'};
|
||||||
|
// const char g_horizontal = '-';
|
||||||
|
// const char g_vertical = '|';
|
||||||
|
|
||||||
|
// Rush 01
|
||||||
|
// const char g_corners[] = {'/', '\\', '/', '\\'};
|
||||||
|
// const char g_horizontal = '*';
|
||||||
|
// const char g_vertical = '*';
|
||||||
|
|
||||||
|
// Rush 02
|
||||||
|
// const char g_corners[] = {'A', 'A', 'C', 'C'};
|
||||||
|
// const char g_horizontal = 'B';
|
||||||
|
// const char g_vertical = 'B';
|
||||||
|
|
||||||
|
// Rush 03
|
||||||
|
// const char g_corners[] = {'A', 'C', 'C', 'A'};
|
||||||
|
// const char g_horizontal = 'B';
|
||||||
|
// const char g_vertical = 'B';
|
||||||
|
|
||||||
|
// Rush 04
|
||||||
|
const char g_corners[] = {'A', 'C', 'A', 'C'};
|
||||||
|
const char g_horizontal = 'B';
|
||||||
|
const char g_vertical = 'B';
|
||||||
|
|
||||||
|
void rush(int x, int y)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
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');
|
||||||
|
}
|
Loading…
Reference in New Issue