0% found this document useful (0 votes)
2 views2 pages

Tejribe 4

The document presents three programming problems related to matrix manipulation and array processing using the Pascal programming language. Problem 1 involves reversing the main and secondary diagonal elements of a matrix, Problem 2 counts the number of rows in a 10x10 matrix that do not contain any elements from the first row, and Problem 3 requires sorting an array based on specific criteria. Each problem is accompanied by a sample code solution.

Uploaded by

sadykowms.ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Tejribe 4

The document presents three programming problems related to matrix manipulation and array processing using the Pascal programming language. Problem 1 involves reversing the main and secondary diagonal elements of a matrix, Problem 2 counts the number of rows in a 10x10 matrix that do not contain any elements from the first row, and Problem 3 requires sorting an array based on specific criteria. Each problem is accompanied by a sample code solution.

Uploaded by

sadykowms.ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Tejribe işi 12

Tema: Düzülen programmalary anyk mysallaryň üsti bilen barlamak we


alnan netijeleri derňemek.
Mesele-1;

Hakyky sanlaryň A(n,n) matrisasy berlen.Esasy we ikinji


diagonallarynyň elementlerini ters tertipde:

Jogaby: Program mesele_1;


uses crt;
const n = 3;
var arr: array[1..n,1..n] of real;
i,j: byte; a: real;
begin
randomize;
for i:=1 to n do begin
for j:=1 to n do begin
arr[i,j] := random();
write(arr[i,j]:4:1); end; writeln; end;
writeln;
for i:=1 to n div 2 do
for j:=1 to n div 2 do
if i = j then begin
a := arr[i,j];
arr[i,j] := arr[n-i+1,n-j+1];
arr[n-i+1,n-j+1] := a; end;
for i:= (n div 2)+1 to n do
for j:=1 to n div 2 do
if j = n-i+1 then begin
a := arr[i,j]; arr[i,j] := arr[j,i];
arr[j,i] := a; end;
for i:=1 to n do begin
for j:=1 to n do
write(arr[i,j]:4:1);
writeln; end; readln;
end.
Mesele-2;
Iki 10x10 ölçegli bitin bahaly G massiw berlen.1-nji setiriň elementlerini
saklamaýan massiwiň setirleriniň sanyny kesgitleýän programma ýazmaly.
Jogaby: Program mesele_2;
uses crt;
const n=5;
var a:array[1..n,1..n] of integer;
q:array[1..n] of integer;
i,j,k,y,t:integer;
b:boolean;
begin
ClrScr; Randomize;
for i:=1 to n do begin
for j:=1 to n do begin
a[i,j]:=random(99)+1; write(a[i,j]:4);
end; writeln; end; k:=0; t:=1;
for i:=2 to n do begin b:=true;
for j:=1 to n do begin
for y:=1 to n do if a[i,j]=a[1,y] then
begin b:=false; break; end; end;
if b then begin k:=k+1; q[t]:=i;
t:=t+1; end; end;
writeln('Sheyle setirlerin sany: ',k);
write('Ol setirlerin nomeri: ');
for i:=1 to t-1 do write(q[i],' ');
readln;
end.
Mesele-3;
Massiwi tertipleşdirmek üçin elementleriň aşakdaky tertibini ulanyp algoritm
we programma düzmeli:maximal element, minimal element ,ululygy boýunça
2-nji iň soňkynyň öňündäki ,ululygy boýunça 3-nji soňundan 3-nji we ş.m

Jogaby: Program mesele_3;


uses crt;
const n=8;
var i,j : byte; imin: byte;k,c : integer; min : integer;
a : array [1..n] of integer;
begin
for i:=1 to n do begin
write('a[',i,']='); readln(a[i]); end;
for i:=2 to n do
for j:=n downto i do begin
if a[j-1]>a[j] then begin
c:=a[j-1];a[j-1]:=a[j];a[j]:=c; end; end;
i:=1;k:=n;
while k>(n div 2)+1 do begin
c:=a[i]; a[i]:=a[k]; a[k]:=c;i:=i+2; k:=k-1; end;
i:=2;k:=0;
while k<(n div 2) do begin
min:=a[i-1];imin:=i-1;
for j:=i-1 to n do
if a[j]<min then begin min:=a[j];imin:=j;end;
c:=a[i]; a[i]:=a[imin]; a[imin]:=c;
i:=i+2; k:=k+1; end;
for i:=1 to n do write(a[i],' '); readln;
end.

You might also like