| Лабораторная работа №16-1Лабораторная работа № 11
Программа:
program lab11;
uses crt;
var y,x,b,m,h,a:real; p:text;
{$i dopf11.pas}
begin clrscr;
assign(p,'rez11pod.pas');
rewrite(p);
writeln(p,'Laboratorna9 rabota 11');
writeln('Laboratorna9 rabota 11');
writeln('Postronie tablic znacheniy funkciy');
writeln(p,'Postronie tablic znacheniy funkciy');
writeln('vvod tablicy');
writeln(p,'vvod tablicy');
write('a=');
read(a);
writeln(p,'a=',a);
write('b=');
read(b);
writeln(p,'b=',b);
write('m=');
read(m);
writeln(p,'m=',m);
h:=(b-a)/m;
x:=a;
writeln('x',' ':14,'f=arctg(x)');
writeln(p,'x',' ':14,'f=arctg(x)');
repeat
y:=f(x);
writeln(x:3:2,'I':7,' ':7,y:3:2);
writeln(p,x:3:2,'I':7,' ':7,y:3:2);
x:=x+h;
until x>=b+h;
readln;
writeln('vypolnil Xatbko Sasha');
writeln(p,'vypolnil Xatbko Sasha');
close(p);
readln;
end.
Подпрограмма:
{$F+}
function F:=arctg(x);
end;
{$F-}
Результат:
a=2
b=4
m=5
vivod tablici
2.00 0.84
2.40 0.88
2.80 0.91
3.20 0.93
3.00 0.95
3.60 0.97
4.00 0.99
vipolnil Xatbko Sasha'
Алгоритм:
Лабораторная работа №12-14
Цель:Составить массив и сделать замену.
Программа:
Program lab12;
uses crt;
type mas1=array[1..10] of real;
mas2=array[1..10,1..10] of integer;
var m:mas1; n:mas2; t1:text; i,j,x,x1,p,q,s,k,l:integer; max,c,min,v:real;
begin
clrscr;
assign (t1,'dan.pas');
reset (t1);
writeln('odnomerniy');
write ('kol-vo elementov=');
readln (x);
for i:=1 to x do begin
read (t1,m[i]);
write (m[i]:1:1,' ');
end;
writeln;
writeln ('dvumerniy');
write ('kol-vo stolbcov x1=');
readln (x1);
for i:=1 to x do begin
for j:=1 to x1 do begin
read (t1,n[i,j]);
write(n[i,j],' ');
end;writeln;
end;
readln;
writeln ('lab13');
writeln ('zamena 1');
max:=m[1];
for i:=1 to x do
if m[i]>max then begin
max:=m[i]; p:=i; end;
writeln ('b[',p,']=',max);
c:=m[1];
m[1]:=m[p];
m[p]:=c;
for i:=1 to x do begin
write (m[i]:1:3,' ');
end;
writeln;
writeln ('zamena 2');
max:=n[1,1];
for i:=1 to x do
for j:=1 to x1 do
if n[i,j]>max then begin
max:=n[i,j]; p:=i; s:=j; end;
writeln ('b[',p,s,']=',max);
q:=n[1,1];
n[1,1]:=n[p,s];
n[p,s]:=q;
for i:=1 to x do begin
for j:=1 to x do begin
write(n[i,j],' ');
end;writeln;
end;
writeln ('lab 14');
writeln ('zamne 1.1');
min:=m[1];
for i:=1 to x-1 do
for j:=i to x do
if m[i] > m[j] then begin
c:=m[j];
m[j]:=m[i];
m[i]:=c;
end;
for i:=1 to x do begin
write (m[i]:1:3,' ');
end;
writeln;
writeln ('zamena 1.2');
min:=n[1,1];
for i:=1 to x-1 do
for k:=i to x do
for j:=1 to x1-1 do
for l:=j to x1 do
if n[i,j]>min then begin
min:=n[i,j]; end;
writeln ('b[',p,s,']=',min);
q:=n[1,1];
n[1,1]:=n[p,s];
n[p,s]:=q;
for i:=1 to x do begin
for j:=1 to x do begin
write(n[i,j],' ');
end;writeln;
end;
readln;
end.
Алгоритм:
Лабораторная Работа №15
Программа:
program lab15;
uses crt;
var z,x,y,a,b:real;
{$i dopfunkc.pas}
begin
clrscr;
write('a=');
read(a);
write('b=');
read(b);
write('x=');
read(x);
write('y=');
read(y);
z:=f(sin(x)+cos(x),x+y)+f(sin(x),cos(y))+f(x-y,x)+f(sin(x)*sin(x)-2,a)+f(a+3,b+1);
writeln('z=',z:3:2);
readln;
readln;
end.
Подпрограмма:
{$F+}
function F(u,t:real):real;
begin
if u>0 then F:=u+sin(t)
else if u<=0 then F:=u+t;
end;
{$F-}
Результат:
a=2 x=5
b=3 y=1
z=13.11
Алгоритм:
Лабораторная работа №16
Программа:
Program lab16;
uses crt;
type mas=array[1..10] of real;
var c:mas; sred:real;
n:integer;
t1,q:text;
i:integer;
{$i sr.pas}
begin
clrscr;
assign (q,'rez16.pas');
rewrite (q);
assign (t1,'dan.pas');
reset (t1);
writeln ('Lab16');
writeln (q,'Lab16');
writeln('massiv F');
writeln (q,'massiv F');
writeln ('kol-vo elementov=');
readln (n);
writeln (q,'kol-vo elementov=',n);
for i:=1 to n do begin
read (t1,c[i]);
write (c[i]:1:1,' ');
end;
sr(c,n,sred);
writeln;
writeln('srednee arifmeticheskoe=',sred:2:1);
writeln (q,'srednee arifmeticheskoe =',sred:2:1);
writeln ('vipolnil Xatbko Sasha');
writeln (q,'vipolnil Xatbko Sasha');
close (q);
readln;
end.
Результат:
Lab16
massiv F
kol-vo elementov=8
srednee arifmeticheskoe =42.0
vipolnil Xatbko Sasha'
Алгоритм:
Лабораторная работа №16-1
Программа:
Program lab161;
uses crt;
type mas1=array[1..10] of real;
mas2=array[1..10,1..10] of integer;
var
m,m1:mas1;
n,n1:mas2;
t1:text;
i,j,x,x1,p,q,s,k,l:integer;
max,c,min,v:real;
{$i Z.pas}
{$i X.pas}
begin
clrscr;
assign (t1,'dan.pas');
reset (t1);
writeln('odnomerniy');
write ('kol-vo elementov=');
readln (x);
for i:=1 to x do begin
read (t1,m[i]);
write (m[i]:1:1,' ');
end;
writeln;
writeln ('dvumerniy');
write ('kol-vo stolbcov x1=');
readln (x1);
for i:=1 to x do begin
for j:=1 to x1 do begin
read (t1,n[i,j]);
write(n[i,j],' ');
end;writeln;
end;
readln;
writeln ('lab13');
z(m,n,x,x1,m1,n1);
writeln ('zamena 1');
for i:=1 to x do begin
write (m[i]:1:3,' ');
end;
writeln;
writeln ('zamena 2');
for i:=1 to x do begin
for j:=1 to x1 do begin
write(n[i,j],' ');
end;writeln;
end;
writeln ('lab 14');
writeln ('zamne 1.1');
u(m,n,x,x1,m1,n1);
for i:=1 to x do begin
write (m[i]:1:3,' ');
end;
writeln;
writeln ('zamena 1.2');
for i:=1 to x do begin
for j:=1 to x1 do begin
write(n[i,j],' ');
end;writeln;
end;
readln;
end.
Подпрограмма 1:
Procedure u(m:mas1;n:mas2;x,x1:integer;var m1:mas1;n1:mas2);
var i,j,p,s,q,k,l:integer;min,c:real;
begin
writeln ('zamne 1.1');
min:=m[1];
for i:=1 to x-1 do
for j:=i to x do
if m[i]>m[j] then begin
c:=m[j];
m[j]:=m[i];
m[i]:=c;
end;
writeln ('zamena 1.2');
min:=n[1,1];
for i:=1 to x-1 do
for j:=1 to x1-1 do
for k:=i to x do begin
for l:=j to x1 do begin
if n[i,j]>n[k,l] then begin
q:=n[i,j];
n[i,j]:=n[k,l];
n[k,l]:=q;
end; end; end;
end;
Подпрограмма 2:
Procedure z(m:mas1;n:mas2;x,x1:integer;var m1:mas1;n1:mas2);
var i,j,p,s,q:integer;max,c:real;
begin
writeln ('zamena 1');
max:=m[1];
for i:=1 to x do
if m[i]>max then begin
max:=m[i]; p:=i; end;
c:=m[1];
m[1]:=m[p];
m[p]:=c;
writeln ('zamena 2');
max:=n[1,1];
for i:=1 to x do
for j:=1 to x1 do
if n[i,j]>max then begin
max:=n[i,j]; p:=i; s:=j; end;
q:=n[1,1];
n[1,1]:=n[p,s];
n[p,s]:=q;
end;
Алгоритм:
Date: 2015-12-24; view: 1296
|