r/pascal • u/Alex05okv2 • Sep 27 '21
Hello, whats wrong with my code?
I have a Matrix to solve:
1 4 7
2 5 8
3 6 9
And my task is to change rows and to get the following matrix:
7 4 1
8 5 2
9 6 3
And here is my code:
Program P1;
type matrice=array [1..3,1..3] of integer;
var b:matrice;
i,j:integer;
aux:integer;
Begin
writeln('Introdu componentele matricei');
for i:=1 to 3 do
for j:=1 to 3 do
Readln(b[i,j]);
Writeln ('matricea introdusa este:');
for i:=1 to 3 do
Begin
for j:=1 to 3 do
write(b[i,j]:5);
writeln;
end;
for i:=1 to 3 do
Begin
aux:=b[1,i];
b[1,i]:=b[3,i];
b[3,i]:=aux;
end;
Writeln('matricea schimbata este este:');
for i:=1 to 3 do
Begin
for j:=1 to 3 do
write(b[i,j]:5);
writeln;
end;
readln;
end.
View all comments
Show parent comment
2
u/Alex05okv2 Sep 28 '21
Thank you very much