Читайте также:
|
|
ТЕХНИКУМ ПРОМИСЛОВОЇ АВТОМАТИКИ
ОДЕСЬКОЇ НАЦШОНАЛЬНОЇ АКАДЕМІЇ ХАРЧОВИХ ТЕХНОЛОГІЙ
Основи програмування
Та алгоритмічні мови.
Протокол №______
Тема: Набор и отладка программ с использованием двумерных массивов
Мета: _______________________________________________________________________________________________________________________________________________________________________________
Програмне забезпечення:___________________________________________
Виконав
Студент II курсу
Групи____________________
_________________________
Викладач: Бачило О.А.
Оцінка__________
Дата____________
м. Одеса 20 -20 учбовий рік
program pr1;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp,b:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
writeln ('Enter b');
readln (b);
for i:=1 to n do
for j:=1 to m do
mas[i,j]:=mas[i,j]*b;
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr2;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
for j:=1 to m do
if i=j then
mas[i,j]:=0;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr3;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
for j:=1 to m do
if i=j then
begin
tmp:=mas[i,1];
mas[i,1]:=mas[1,j];
mas[1,j]:=tmp;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr4;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for j:=1 to n do
begin
mas[1,j]:=0;
mas[n,j]:=1;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr5;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
for j:=1 to m do
if i=j then
write (mas[i,j],' ');
writeln;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr6;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for j:=1 to m do
begin
tmp:=mas[1,j];
mas[1,j]:=mas[n,j];
mas[n,j]:=tmp;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr7;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp,b:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] < mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
b:=0;
for i:=1 to n do
for j:=1 to m do
b:=b + mas[i,j];
writeln('Sa = ', b/(n*m));
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr8;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
begin
tmp:=mas[i,1];
mas[i,1]:=mas[i,2];
mas[i,2]:=tmp;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr9;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp,b:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
b:=0;
for i:=1 to n do
begin
for j:=1 to m do
b:=b+mas[i,j];
writeln('s',i,'=',b/m);
b:=0
end;
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr10;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
begin
tmp:=mas[i,1];
mas[i,1]:=mas[i,m];
mas[i,m]:=tmp;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr11;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for j:=1 to m do
begin
tmp:=mas[1,j];
mas[1,j]:=mas[2,j];
mas[2,j]:=tmp;
end;
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
program pr12;
var
mas: array [1..10, 1..10] of integer;
i,j,n,m,a,tmp,b:integer;
begin
writeln('Enter n');
readln (n);
writeln ('Enter m');
readln(m);
writeln ('Enter mas');
for i:=1 to n do
for j:=1 to m do
readln(mas[i,j]);
for i:=1 to n do
for j:=1 to m do
for a:=j+1 to m do
if mas[i,j] > mas [i,a] then
begin
tmp:=mas[i,j];
mas[i,j]:=mas[i,a];
mas[i,a]:=tmp;
end;
for i:=1 to n do
for j:=1 to m do
if i=j then
b:=b+mas[i,j];
writeln ('summa=',b);
for i:=1 to n do
begin
for j:=1 to m do
write(mas[i,j],' ');
writeln;
end;
readln
end.
Дата добавления: 2015-08-18; просмотров: 42 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
Французские дети не плюются едой | | | Снаружи Внутри |