-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathback00.c
60 lines (56 loc) · 1.59 KB
/
back00.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* back00.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atoulous <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/01 20:35:52 by atoulous #+# #+# */
/* Updated: 2015/11/01 20:38:56 by atoulous ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char test0(int l, int h, int x, int y)
{
if (l == 1 && h == 1)
return ('o');
else if (l == x && h == 1)
return ('o');
else if (l == 1 && h == y)
return ('o');
else if (l == x && h == y)
return ('o');
else if (h == 1 || h == y)
return ('-');
else if (l == 1 || l == x)
return ('|');
else
return (' ');
}
char *back00(int x, int y)
{
int lc;
int hc;
char *tab;
int index;
lc = 1;
hc = 1;
index = 0;
if ((tab = (char*)malloc(sizeof(*tab) * ((x + 1) * y + 1))) == NULL)
return (NULL);
while (hc <= y)
{
while (lc <= x)
{
tab[index] = test0(lc, hc, x, y);
lc++;
index++;
}
tab[index] = '\n';
lc = 1;
hc++;
index++;
}
tab[index] = '\0';
return (tab);
}