Re: pascan vấn đề thi hgs tin học
uses crt;
var a:array[1..100,1..100] of integer;
x,i, j ,n ,m, k ,l : integer;
procedure nhap;
begin
Write(' nhap so hang ');
readln

;
write(' nhap so cot ');
readln(m);
for i := 1 to n do
for j := 1 to m do
begin
write(' nhap a[',i,',',j,' ]= ');
readln(a[i,j]);
{ a[i,j]:=random(10); {PO}
end;
end;
procedure inmatran;
begin
for i:= 1 to n do
begin
for j:= 1 to m do write(a[i,j]:4);
writeln;
end;
end;
procedure hoandoi(var x,y:integer);
var t:integer;
begin
t:=y;
y:=x;
x:=t;
end;
procedure sapxeptang(var x,y:integer);
begin
if x>y then
hoandoi(x,y);
end;
function nguyento(x:integer):boolean;
var i:integer;
begin
nguyento:=true;
if (x=0) or (x=1) then nguyento:=false;
for i:= 2 to x-1 do if x mod i = 0 then nguyento:=false;
end;
function duongcheop(nl:integer):integer;
begin
x:=0;
for i:=1 to nl do
x:=x+a[i,nl+1-i];
duongcheop:=x;
end;
function duongcheoc(nl:integer):integer;
begin
x:=0;
for i:=1 to nl do
x:=x+a[i,i];
duongcheoc:=x
end;
Begin clrscr;
{ randomize; }
nhap;
inmatran;
write(' nhap 2 hang can doi vi tri');
readln(k,l);
for i:= 1 to m do
hoandoi(a[k,i],a[l,i]);
inmatran;
writeln;
for i:= 1 to m do
for j:= 2 to n do
for k:= 1 to j do
sapxeptang(a[k,i],a[j,i]);
for i:=1 to n do
for j:=2 to m do
for k:=1 to j do
sapxeptang(a[i,k],a[i,j]);
inmatran;
readln;
{ for i:= 1 to n do
for j:= 1 to m -1 do
for k:= 2 to m do
begin
sapxeptang(a[i,j],a[i,k]);
if a[m,i]>a[1,i+1] then hoandoi(a[m,i],a[1,i+1]);
end;
}
for i := 1 to n do
for j := 1 to m do
if nguyento(a[i,j]) = true then writeln(a[i,j], 'la nguyen to tropng mang');
readln;
if m=n then write('tong duong cheo chinh ',duongcheoc

,' duong cheo phu ' , duongcheop

);
readln;
end.
ĐÂY LÀ Đáp án chính xác đề thầy sy cho hôm chủ nhật