-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.c
63 lines (51 loc) · 968 Bytes
/
program.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
61
62
63
#include <stdlib.h>
#include <string.h>
#include <salagaio.h>
#define PINNED_ARRAY_SIZE 20
unsigned int pinned_array[PINNED_ARRAY_SIZE] __attribute__((section(".pinned_array_section")));
#define WIDTH 10
void print_negative_slope()
{
int x;
int y;
// Slope is -0.5
int x_incr = 1;
int y_incr = 2;
int _HEIGHT = WIDTH;
for (y = 0; y < _HEIGHT; y += y_incr) {
for (x = 0; x < WIDTH; x += x_incr) {
if (x == y) {
putchar('*');
} else {
putchar(' ');
}
}
putchar('\n');
}
}
void print_positive_slope()
{
int x;
int y;
// Slope is 0.5
int x_incr = 1;
int y_incr = 2;
int _HEIGHT = WIDTH;
for (y = 0; y < _HEIGHT; y += y_incr) {
for (x = WIDTH; x > 0; x -= x_incr) {
if (x == y) {
putchar('*');
} else {
putchar(' ');
}
}
putchar('\n');
}
}
int main()
{
print_negative_slope();
print_positive_slope();
print_negative_slope();
return 0;
}