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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
| #include <conio.h>
#include <bios.h>
#include <math.h>
#include <dos.h>
void run_string(int xT,int yT);
double f(double x);
void graphic(int n);
void graphinterface(int grdr, int grmode) //Їа®ўҐаЄ* Ё*ЁжЁ*«Ё§*жЁЁ Ја*дЁзҐбЄ®Ј® ०Ё¬*
{ int errorcode;
initgraph(&grdr, &grmode, "");
errorcode = graphresult();
if (errorcode!=0)
{ printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press 'ENTER' to halt");
getch();
exit(1);
}
}
struct time t;
int main(void)
{ int key = 0, m;
char time[9];
graphinterface(EGA, EGAHI);
setfillstyle(EMPTY_FILL, GREEN);
int xT=getmaxx(), yT=180;
while(key != 7181)
{ if(bioskey(1) != 0) key = bioskey(0);
m=!m;
setactivepage(m);
cleardevice();
setcolor(getbkcolor());
bar3d(560,0,640,10,0,0);
gettime(&t);
sprintf(time, "%2d:%2d:%2d", t.ti_hour, t.ti_min, t.ti_sec);
setcolor(WHITE);
outtextxy(570, 3, time);
if (xT==-10) xT=getmaxx();
xT=xT-1;
run_string(xT,yT);
setvisualpage(m);
delay(100);
}
cleardevice();
graphic(1);
graphic(2);
graphic(3);
closegraph();
return 0;
}
void run_string(int xT,int yT)
{ setfillstyle(SOLID_FILL, BLACK);
bar(xT,yT,xT+210,yT+8);
setcolor(14);
outtextxy(xT, yT, "LAB#5; TV-92; Press Enter to continue");
}
double f(double x)
{ double y,a=2,b=0;
if(x<3 && a*x>0) y = log(a*x);
else
{ if(x>6) y = abs(a*b + x);
else y = b + pow(x,a);
}
return(y);
}
void graphic(int n)
{ graphinterface(EGA, EGAHI);
double x0, x1, y1, x2, y2;
int MaxX =0.5*getmaxx(), MaxY = 0.5*getmaxy(),i,j,kx = 25, ky = 25, key=1;
setviewport(0.5*getmaxx(), 0.5*getmaxy(), getmaxx(), getmaxy(),0);
while (key!=7181)
{ cleardevice();
key = 0;
setcolor(WHITE);
setlinestyle(0,1,3);
line(0,-MaxY,0,MaxY);
line(-MaxX,0,MaxX,0);
line(MaxX,0,MaxX-10,5);
line(MaxX,0,MaxX-10,-5);
line(0,-MaxY,5,-MaxY+10);
line(0,-MaxY,-5,-MaxY+10);
outtextxy(4,5,"0");
outtextxy(MaxX-8,5,"x");
outtextxy(8,-MaxY+5,"y");
setlinestyle(0,0,2);
for(i=-MaxX;i<=MaxX;i++) line(i*kx,2,i*kx,-2);
for(j=-MaxY;j<=MaxY;j++) line(2,j*ky,-2,j*ky);
outtextxy(-MaxX+20, MaxY-15, "Press Enter to continue");
setcolor(RED);
x0 = -MaxX+10;
while (x0<=MaxX-10)
{ x1 = (x0-0.1)*kx;
x2 = x0*kx;
if (n==1) { y1 = ky*(x0-0.1)*(x0-0.1)*(x0-0.1); y2 =ky*x0*x0*x0;}
if (n==2) { y1 = pow(x0-0.1+5,2)/pow(x0-0.1-6,2); y2 = pow(x0+5,2)/pow((x0-6),2);}
if (n==3) { y1 = f(x0-0.1); y2 = f(x0); }
line(x1,-y1, x2,-y2);
x0+=0.1;
}
key = bioskey(0);
if (key==561) kx+=25;
if (key==3117) kx-=25;
if (key==7181) break;
}
closegraph();
} |