Pascal Шестериков

Графические возможности языка программирования Pascal ABC. 
Конспект
1) Круг(Шестериков)
Program asdasd1;
uses GraphABC;
Begin
SetPenwidth(10);
SetPenColor(clNavy);
circle(350,250,200);
setwindowwidth(650);
setwindowheight(600);
FloodFill(350,250,clYellow);
End.



2) Объемные(Шестериков)
Program zsdgvdgh;
     uses GraphABC;
Begin
     SetPenwidth(5);
     circle(150,150,100);
     setwindowwidth(660);
     setwindowheight(570);
     Pen.Style:=psDot;
     arc(155,75,100,335,198);
     TextOut(120,260,'Сфера');
     Pen.Style:=psSolid;
     Rectangle(450,100,600,250);
     Pen.Style:=psDot;
     Line(480,70,480,220);
     Line(480,220,630,220);
     Line(480,220,450,250);
     Pen.Style:=psSolid;
     Line(630,220,630,70);
     Line(630,70,480,70);
     Line(480,70,450,100);
     Line(600,250,630,220);
     Line(630,70,600,100);
     TextOut(520,260,'Куб');
     Line(300,520,400,450);
     Line(300,520,200,450);
     Pen.Style:=psDot;
     Line(400,450,200,450);
     Pen.Style:=psSolid;
     Line(300,300,300,520);
     Line(300,300,400,450);
     Line(300,300,200,450);
     TextOut(260,530,'Пирамида');
End.
3)Треугольники(Шестериков)
program v_dotku_by;
uses graphABC;
begin
  SetWindowSize(600,600);
  moveto(100,100);
  setpencolor(clBlack);
  SetPenWidth(5);
  lineto(150,10);
  lineto(200,100);
  lineto(100,100);
  FloodFill(150,50,clGreen);
  TextOut(110,120,'Равносторонний');
   SetpenColor (clBrown);
    Line (150,150,200,250);
    Line (150,150,60,180);
    Line (60,180,200,250);
    FloodFill(180,230,clYellow);
    TextOut(100,270,'Разносторонний');
    SetPenwidth(8 );
    SetpenColor (clNavy);
    Line (300,10,450,100);
    Line (450,100,300,100);
    Line (300,100,300,10);
    FloodFill(320,40,clSilver );
    TextOut(300,120,'Прямоугольный');
     moveto(400,290);
  SetPenwidth(3);
  setpencolor(clSkyBlue);
  lineto(500,290);
  lineto(300,210);
  lineto(400,290);
  Floodfill(450,280,clRed);
  TextOut(400,320,'Тупоугольный');
  moveto(150,350);
  SetPenwidth(5);
  setpencolor(clBlack);
  lineto(180,500);
  lineto(120,500);
  lineto(150,350);
  FloodFill(160,460,clOlive);
  TextOut(100,520,'Равнобедренный');
end.
4)Четырехугольники(Шестериков)
Program  mad_max;
     uses GraphABC;
Begin
 SetWindowSize(600,600);
  moveto(100,100);
  SetPenWidth(3);
  setpencolor(clgreen);
  rectangle(100,100,200,200);
  FloodFill(150,150,clBlack);
  TextOut(130,210,'Квадрат');
  SetPenColor(clGreen);
   SetPenwidth( 6);
   Line(370,140,470,140);
   Line(470,140,410,200);
   Line(410,200,310,200);
   Line(310,200,370,140);
   FloodFill(400,170,clGray);
   TextOut(320,210,'Параллелограмм');
   SetPenWIdth(4);
  setpencolor(clOlive);
  rectangle(300,270,400,320);
  FloodFill(310,280,clTeal);
  TextOut(300,325,'Прямоугольник');
  SetPenColor(clMaroon);
  SetPenwidth(7);
   Line(100,260,200,260);
   Line(200,260,250,320);
   Line(250,320,50,320);
   Line(50,320,100,260);
   FloodFill(120,300,clRed);
   TextOut(100,340,'Трапеция');
  end.

5)Наклоненная призма(Шестериков)
Program ergherh;
   uses GraphABC;
Begin
   SetWindowSize(300,300);
   SetPenwidth(3);
   Pen.Style:=psDot;
   Line(40,150,170,150);
   Line(40,150,10,190);
   Line(70,50,40,150);
   Pen.Style:=psSolid;
   Line(70,50,200,50);
   Line(40,90,170,90);
   Line(70,50,40,90);
   Line(200,50,170,90);
   Line(10,190,140,190);
   Line(170,150,140,190);
   Line(200,50,170,150);
   Line(40,90,10,190);
   Line(170,90,140,190);
   Floodfill (80,60,clGreen);
   floodfill (80,100,clGreen);
   floodfill (180,100,clGreen);
   TextOut(10,200,'Наклоненная призма');
End.

6)Четырехугольная усеченая пирамида(Шестериков)
Program afgaseg;
uses GraphABC;
begin
SetWindowWidth(600);
SetWindowHeight(600);
SetPenColor (clBlack);
SetPenWidth(3);
Line(200,300,100,500);
Line(350,300,450,500);
Line(400,250,550,400);
Line(200,300,350,300);
Line(400,250,350,300);
Line(200,300,250,250);
Line(400,250,250,250);
Line(550,400,450,500);
Line(450,500,100,500);
Pen.Style:=psDot;
Line(100,500,200,400);
Line(200,400,550,400);
Line(200,400,250,250);
floodfill(400,300,clYellow);
floodfill(300,280,clYellow);
floodfill(300,450,clYellow);
TextOut(150,200,'Четырехугольная усеченая пирамида');
end.

7)Четырехугольная пирамида
Program wegwe;
uses GraphABC;
Begin
  SetWindowSize(420,500);
  SetPenwidth(3);
  Pen.Style:=psDot;
  Line(100,300,300,300);
  Line(100,300,50,400);
  Line(150,100,100,300);
  Pen.Style:=psSolid;
  Line(50,400,250,400);
  Line(300,300,250,400);
  Line(150,100,300,300);
  Line(150,100,50,400);
  Line(150,100,250,400);
  Floodfill(250,350,clLightBlue);
  Floodfill(200,350,clLightBlue);
  TextOut(50,420,'Четырехугольная пирамида');
End.



Использование растровых изображений.
Построение графиков и диаграмм

2.Учёные
Program uchenIe;
   uses GraphABC;
var pic : integer;
begin
  ClearWindow (clRed);
  SetWindowSize (450, 500);
  pic:= LoadPicture ('Newton.jpg');
  DrawPicture (pic, 60, 110, 100, 100);
  TextOut(90,210,'Ньютон');
  pic:= LoadPicture ('bohr.jpg');
  DrawPicture (pic, 160, 210, 100, 100);
  TextOut(200,310,'Бор');
  pic:= LoadPicture ('Einstein.jpg');
  DrawPicture (pic, 60, 310, 100, 100);
  TextOut(80,410,'Эйнштейн');
  pic:= LoadPicture ('Galileo.jpg');
  DrawPicture (pic, 260, 290, 100, 100);
  TextOut(290,390,'Галилей');
  pic:= LoadPicture ('Leonardo.jpg');
  DrawPicture (pic, 260, 140, 100, 100);
  TextOut(280,240,'Л. да Винчи');
end.

 

3. Яблоко
Program rofl;
uses GraphABC;
var b, a, x, y, w, h: integer;
begin
SetWindowSize (250, 300);
b:= LoadPicture ('TOWER.jpg');
a:= LoadPicture('APPLE.gif');
ClearWindow;
x:= 150; y:= 5; w:= 30; h:= 60;
While x<400 do
begin
DrawPicture (b, 0, 0);
DrawPicture (a, x, y, w, h);
y:= y+10; x:=x+3; w:= w+1; h:= h+1;
sleep(20);
Redraw;
end;
end.
4. Графики
 а)y = 0.5x*cos x, на промежутке [-12; 12];
Program ffonettiwr;
uses crt, GraphABC;
var  x0, y0, x1, y1, k: integer; x, y: real;
begin
SetWindowSize (640, 400);
x0:= 320; y0:= 200; k:= 20;
line (20, y0, 620, y0);
line (x0, 20, x0, 380);
SetPenColor (clBlue);
x:= -12;
While x<= 12 do
begin
y:= 0.5*x*cos(x);
x1:= trunc(x0+x*k);
y1:= trunc(y0+y*k);
circle(x1, y1, 2);
x:= x + 0.02;
end;
end.


  б) y = sinx*cos 2x, на промежутке [-15; 15]
Program jesus;
uses crt, GraphABC;
var  x0, y0, x1, y1, k: integer; x, y: real;
begin
SetWindowSize (640, 400);
x0:= 320; y0:= 200; k:= 20;
line (20, y0, 620, y0);
line (x0, 20, x0, 380);
SetPenColor (clBlack);
x:= -15;
While x<= 15 do
begin
y:= sin(x)*cos(2*x);
x1:= trunc(x0+x*k);
y1:= trunc(y0+y*k);
circle(x1, y1, 2);
x:= x + 0.02;
end;
end.

Задачи по предметам
1. Астрономия
  Планета солнечной системы на экран
Program LOL; 
Uses GraphABC;
Var pic1,pic2:integer;
Begin
SetWindowSize(600,400);
pic1:=LoadPicture('SKY.gif');
DrawPicture(pic1,1,1,799,599);
pic2:=LoadPicture('
earth.gif');
DrawPicture(pic2,220,100);
End.


 Движение спутника на фоне Земли
Program grtl;
Uses GraphABC;
Var pic1,pic2,pic3,x:integer;
Begin
SetWindowSize(1000,500);
pic1:=LoadPicture('sky.gif');
pic2:=LoadPicture('earth.gif');
pic3:=LoadPicture('sputnik.jpg);
SetPictureTransparent(pic3,true);
LockDrawing;
while x<1000 do
begin
inc(x,10);
DrawPicture(pic1,1,1,999,499);
DrawPicture(pic2,-150,250,1300,800);
DrawPicture(pic3,x,100,50,40);
redraw; sleep(20);
end;
End.



  Движение планет вокруг Солнца по круговым орбитам
Program planety;
     uses crt, GraphABC;
Var fon,a,b,c,x0,y0,x,y,u,R:integer;
Begin

SetWindowSize(170,150);
fon:=LoadPicture('sky.gif');
a:=LoadPicture('sun.jpg');
b:=LoadPicture('earth.gif');
c:=LoadPicture('mars.jpg');
x0:=75; y0:=55;
R:=50; u:=1;
while u<=360 do
begin
ClearWindow;
DrawPicture(fon,0,0);
DrawPicture(a,70,60,30,30);
x:=round(x0+R*cos(pi*u/180));
y:=round(y0-R*sin(pi*u/180));
DrawPicture(b,x,y,10,10);
x:=round(x0+R*0.8*cos(pi*u/180));
y:=round(y0-R*0.8*sin(pi*u/180));
DrawPicture(c,y,x,10,10);
U:=u+1;
sleep(30);
Redraw;
end;
End. 




2. География
  Вывести карту Беларуси с парками
Program joke;
Uses GraphABC;
Const Par:array[1..4]of string=('Беловежская пуща', 'Браславские озёра', 'парк Припятский', 'парк Нарочанский');
Plo:array[1..4]of real=(87.5, 71.5, 82.4, 94.0); koe=5;
Clr:array[1..4]of integer=(cl
Magenta,clBrown,clYellow,clDarkGray);
Var pic,i,sto:integer; min:real;
Begin
SetWindowSize(600,500);
pic:=LoadPicture('karta.gif');
DrawPicture(pic,1,1,599,499);
SetBrushColor(clRed);
 min:=100;
for i:=1 to 4 do if plo[i]<min then min:=plo[i];
for i:=1 to 4 do
begin
SetBrushColor(Clr[i]);
writeln(par[i]:17,plo[i]:5:1);
Rectangle(185,(i-1)*16+4,195,(i-1)*16+14);
end;
SetBrushColor(Clr[1]);
sto:=round(sqrt(plo[1]-min))*koe+25; rectangle(20,370,20+sto,370+sto);
SetBrushColor(Clr[2]);
sto:=round(sqrt(plo[2]-min))*koe+25; rectangle(230,55,230+sto,55+sto);
SetBrushColor(Clr[3]);
sto:=round(sqrt(plo[3]-min))*koe+25; rectangle(280,400,280+sto,400+sto);
SetBrushColor(Clr[4]);
sto:=round(sqrt(plo[4]-min))*koe+25; rectangle(200,120,200+sto,120+sto);
End.   





 Диаграммы о площади и глубине
Program rgwegwe;
Uses GraphABC;
Const k=6;
Oze:array[1..k]of string=('Долгое', 'Ричи', 'Соро', 'Вечелье','Лепельс', 'Кривое');
Glu:array[1..k]of real=(53.6, 51.9, 36.3, 35.9, 33.7, 31.5); km=30;
Plo:array[1..k]of real=(2.6, 12.84, 5.31, 1.36, 10.18, 4.5);
Clr:array[1..k]of integer=(clRed, clGreen, clBlue, clYellow, clAqua, clFuchsia);
Var i,pic:integer; min_gl,min_pl:real;
Begin
SetWindowSize(600,800); pic:=LoadPicture('ris/belarus.gif');
DrawPicture(pic,1,1,599,499); writeln('Озеро':7,'Глубина':8,'Площадь':8);
min_gl:=100; min_pl:=100;
for i:=1 to k do
begin
if glu[i]<min_gl then min_gl:=glu[i]; if plo[i]<min_pl then min_pl:=plo[i];
end;
for i:=1 to k do
begin
SetBrushColor(Clr[i]);
writeln(oze[i]:7,glu[i]:7:1,plo[i]:7:2);
Rectangle(180,(i-1)*16+18,190,(i-1)*16+28);
Rectangle(i*km,750,i*km+20,750-round((glu[i]-min_gl)*12+10));
Rectangle(250,470+i*km,250+round((plo[i]-min_pl)*25+10),470+20+i*km);
end;
SetBrushColor(ClWhite); SetFontColor(clBlue);
SetFontSize(26); TextOut(40,750,'Глубина');
SetFontSize(26); TextOut(280,670,'Площадь');
End.


   Карта Европы
Program tyjk;
uses GraphABC;
Const A:array[1..8] of real=(82.5,60.9,60.4,58.8,43.8,38.1,16.3,11.1);
      B:array[1..8] of string=('Германия','Франция','Великобритания','Италия','Испания','Польша','Нидерланды','Греция');
Var k,i,R:integer;
Begin
SetWindowSize(607,615);
writeln('Численность населения');
k:=LoadPicture('Europe.jpg');
DrawPicture(k,0,160,500,400);
writeln('Число':15,' млн. чел. ':13);
for i:=1 to 8 do
writeln(i,B[i]:15,'',A[i]:7:1,' ìëí.÷åë. ');
setBrushColor(clRed);
R:=round(sqrt(A[1]/pi));
circle(270,323,R);
R:=round(sqrt(A[2]/pi));
circle(145,368,R);
R:=round(sqrt(A[3]/pi));
circle(120,330,R);
R:=round(sqrt(A[4]/pi));
circle(270,465,R);
R:=round(sqrt(A[5]/pi));
circle(45,475,R);
R:=round(sqrt(A[6]/pi));
circle(358,320,R);
R:=round(sqrt(A[7]/pi));
circle(178,325,R);
R:=round(sqrt(A[8]/pi));
circle(438,503,R);
End.




3. Биология
  Через сколько дней уровень загрязнения воды уменьшится в N раз, если каждый день он уменьшается на P %
Program zagryazneniye;
Var N,P,i,t,u0:integer;
u:real;
Begin
write('уровень загрязнения воды ');
readln(u0);
write('коэффициент уменьшения ');
readln(N);
write('значение уменьшения ');
readln(P); 
t:=0; u:=u0;
while u>u0 div N do
begin
u:=u-u*p/100; 
t:=t+1;
end;
write('Через ',t,' дней');
End.  



 Через сколько дней количество атомов радиоактивного изотопа Иод-131 уменьшится
в 100 раз, если период полураспада (время уменьшения количества атомов вдвое)
составляет 8.14 дня.

Program ewfgw;
Const ppr=8.14; k=100;
Var dni,mn:integer; mt,z_d:real;
Begin
mn:=100; mt:=mn;//масса начальная и текущая
while mn/mt<k do
begin
inc(dni); mt:=mn*power(2,-dni/ppr);
writeln(dni:8,mt:9:2,mn/mt:8:2);
end;
writeln('Дни':8,'Тек.масса':11,'Коэфф.':7);
writeln('Точный ответ ',-ppr*ln(1/100)/ln(2):4:2,' дня')
End.




  Через сколько дней выздоровеет больной, т.е. через сколько дней концентрация
болезнетворных бактерий в крови уменьшится с 50 до 12 единиц. В результате
применения лекарства концентрация бактерий ежедневно уменьшается на 20% по
сравнению с предыдущим днём.
Program dfbhk;
Const na=50; ko=12; pr=20;
Var dni:integer; kon:real;
Begin
kon:=na;
writeln('Дни ':5,' Концентрация':10);
while kon>ko do
begin 
kon:=kon*(1-pr/100); inc(dni); writeln(dni:4,kon:10:2)
end;
End.


4. Физика
а)
Program sbsbt;
uses GraphABC;
Var p,R:integer;
Begin
SetWindowSize(640,480);
write('Введите расстояние от предмета до зеркала (5-100): ');
readln(R);
p:=LoadPicture('robot.jpg')
SetPenColor(clGreen);
SetPenWidth(9);
Line(320,50,320,400);
Line(50,400,590,400);
DrawPicture(p,320+R,100,200,290);
DrawPicture(p,320-R,100,-200,290);
SetPenColor(clGray);
SetPenWidth(4);
Line(trunc(120+R/2),100,trunc(520-R/2),100);
End.


б)
Program ebweb;
uses GraphABC;
Var u,x,y:integer;
Begin
SetWindowSize(300,400);
write('Введите угол падения луча(5-85): ');readln(u);
SetPenColor(clRed);
SetPenWidth(4);
Line(150,50,150,350);
SetPenColor(clGreen);
Line(0,200,300,200);
FloodFill(50,250,clGreen);
SetPenColor(clBlack);
x:=abs(round(150*sin(pi/180*(180-u))));
y:=abs(round(150*cos(pi/180*(180-u))));
Line(150,200,150-x,200-y);
x:=round(150*sin(pi/180*u));
y:=round(150*cos(pi/180*u));
Line(150,200,150+x,200-y);
SetPenColor(clBlue);
x:=abs(round(150*sin(pi/180*(270+u))));
y:=abs(round(150*cos(pi/180*(270+u))));
Line(150,200,150+xs,200+y);
End.


Комментариев нет:

Отправить комментарий