|
Fizik jarayonlarni kompyuterda modellashtirish
|
bet | 83/135 | Sana | 22.05.2024 | Hajmi | 15,08 Mb. | | #250347 |
Bog'liq Fizik jarayonlarni kompyuterda modellashtirish2-misol.
1- Misol:
1 # include
2 # include
3 void main ( )
4 void main ( )
5 { gd=0;
6 initgraph (&gd, &gm, ' ');
7 setcolor (BLUE);
8 setcolor (14);
9 rectangle (120, 130, 240, 250);
10 setcolor (6);
11 line (120, 130, 180, 80);
12 setcolor (2);
13 line (180, 80, 240, 130);
14 setcolor (14);
15 rectangle (160, 160, 200, 250);
16 setcolor (4);
17 setfillstyle(7, 9);
18 circle( 300, 300, 50);
19 floodfill (300, 300, 4);
20 getch( );
21 closegraph ( );
22}
4. Grafik rejimida shriftlar
Grafik rejimi xolatida turli shriftlardan foydalanib matnlarni xam yozsa bo’ladi. SHriftlar .chr kengaytmali fayllarda saklanadi. Ular .bgi
Fayllari bilan bitta katalogdas aklanishi shart.
1. outtextxy (x, y, 'matn'); - matnni yozish; bu erda x va y matn boshlanadigan
Nuqta koordinatalari; masalan: outtextxy (10, 10, 'Mirzaev K. 212-07 Aty‟);
2. settextstyle (sh, n, r); mant shriftini o’ rnatish; bu yerda sh - shriftnomeri
(0 - vektorli shrift, 1 - standart shrift); n - shrift yo’nalishi (0 - chapdan
O’ngga, 1 - kuyidan yuqoriga yozish); r - shrift razmeri (oddiy shriftda 1,
Vektorli shriftda 4 deb olinadi);
3. settextjustify (h, v) - yozilgan qatorni tekislaydi. U outtextxy
protsedurasidankeyinyoziladi. Bu yerda h - gorizontal tekislash; v -vertikal tekislash; Gorizontal tekislash uchun: 0 - chapga; 1- markazga; 2 -o’ngga. Vertikal tekislash uchun: 0 - pastga; 1 - markazga; 2 - yukoriga.
4. set user char size - vector shriftlari uchun bir xi lsimvollarning eni va
Buyini o’ rnatadi. Masalan: setUserCharSize(x1, y1, x2, y2);
3-misol. Funksiyalarning grafiklarini chizish.
1 # include
2# include
3 # include
4 void main ( )
5 { int i, j, gd, gm ; float x, y;
6 gdq0; initgraph (&gd, &gm, " ");
7 setcolor (14);
8 line (320, 0, 320, 480);
9 line (0, 240, 640, 240);
10 line (480, 0, 480, 235);
11 line (325, 120, 635, 120);
12 line (160, 245, 160, 475);
13 line (0, 360, 315, 360);
14 line (480, 245, 480, 475);
15 line (325, 360, 635, 360);
16 x =-10; outtextxy(10, 20, ' yqsin(x) grafigi');
17 do
18 { y = sin(x);
19 putpixel (160 + 10*x, 120 - y, 5);
20 x = x+0.001; }
21 while (x22 x1 = -10; outtextxy(10, 20, ' y=cos(x) grafigi');
23 do
24 { y = cos(x1);
25 putpixel (480 + 20*x1, 120 - 20*y1, 6);
26 x1 q =1+0.001; }
27 while (x1 <=10);
28 x2 = -10; outtextxy(10, 20, ' y=exp(x) grafigi');
29 do
30 { y2 = exp(x2);
31 putpixel (160 + 10*x2, 360 - 20*y2, 7);
32 x2 = x2+0.001; }
33 while (x2 <=10);
34 x3 = -10; outtextxy(10, 20, ' y=ln(x) grafigi');
35 do
36 { y3 = ln(x3);
37 putpixel (480 + 10*x3, 360 - y3, 8);
38 x3 = x3+0.001; }
39 while (x3 <=10); getch( ); closegraph( ); }
|
| |