-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab9-4.c
70 lines (48 loc) · 1.15 KB
/
lab9-4.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
64
65
66
67
68
69
#include<stdio.h>
#include<math.h>
#define szer 50
#define wys 40
#define dol_x -0.9
#define gora_x 8
#define dol_y -2.5
#define gora_y 2.5
double funkcja_b (double x) {
return x*sin(x);
}
char rysunek[szer][wys];
void rysuj(int x, int y, char znak) {
if (0<=x && x<szer && 0<=y && y<wys)
rysunek[x][y] = znak;
}
int interpoluj (double x, double a, double b, int n) {
return floor((x-a)*n/(b-a));
}
int f_b (int x) {
return
interpoluj(
funkcja_b( ((double)gora_x - (double)dol_x)/szer*x + dol_x),
dol_y, gora_y, wys
);
}
main () {
int x,y, poziom, pion;
printf("\nWYKRES FUNKCJI:\n\n ");
for (x=0; x<szer; x=x+1)
for (y=0; y<wys; y=y+1)
rysuj(x, y, ' ');
pion = interpoluj(0, dol_x, gora_x, szer);
for(y=0; y<wys; y=y+1)
rysuj(pion, y, '|');
poziom = interpoluj(0, dol_y, gora_y, wys);
for(x=0; x<szer; x=x+1)
rysuj(x, poziom, '-');
rysuj(pion, poziom, '+');
for (x=0; x<szer; x=x+1)
rysuj(x, f_b(x), 'o');
for (y=wys-1; y>=0; y=y-1) {
for (x=0; x<szer; x=x+1)
printf("%c", rysunek[x][y]);
printf("\n ");
}
printf("\n\n");
}