ahoj... po dlouhe dobe jsem se zacal znovu ucit pascal.. take hlavne kvuli doucovani, ktere obcas davam... mam problem ale uz se zaklady. delam program, ktery na obe diagonaly matice nacte jednicky. a delam to pomoci funkci. ale porad mi to vypisuje jednicky vsude. mohl by jste mi na to nekdo kouknout prosim a poradit. prikladam svuj kod. diky moc. petr
program mat_diag_jednicky;
uses crt;
const jedna = 1;
var mat : array[1..10,1..10] of integer;
i, j:integer;
function vycisti(i,j : integer):integer;
begin
for i:=1 to 10 do begin
for j:=1 to 10 do begin
mat[i][j]:=0;
vycisti:=mat[i][j];
end;
end;
end;
function zapis(i,j:integer):integer;
begin
for i:=1 to 10 do begin
for j:=1 to 10 do begin
if i = j then mat[i][j]:=jedna;
end;
end;
for i:=1 to 10 do begin
for j:=1 to 10 do begin
zapis:=mat[i][j];
end;
end
end;
begin
clrscr;
for i:=1 to 10 do begin
for j:=1 to 10 do begin
write(vycisti(i,j));
end;
writeln;
end;
writeln;
readln;
for i:=1 to 10 do begin
for j:=1 to 10 do begin
write(zapis(i,j));
end;
writeln;
end;
readln;
end.