Aufgabenstellung: Schreiben Sie ein Unterprogramm, dass eine 5 × 5-Matrix übergeben bekommt und eine Kopie
dieser Matrix an einen Ausgabeparameter übergibt.Welche Typdeklarationen sind hier notwendig?
nun habe ich schon folgendes getestet:
ich habe probiert in der einen unit, die matrix zu initalisieren und sie in eine input.txt gespeichert und dann in hauptprogramm habe ich einfach die zahlen aus der input.txt in die output.txt einlesen lassen.
ich bin nun soweit, dass ich mein programm habe, allerdings ohne unterprogramm:
PROGRAM Matrix(input, output, mout);
const
n=5; m=5;
var
x: Array[1..n] of Array[1..m] of integer;
i,j,max : integer;
mout : text;
begin
assign(mout, 'output.txt');
reset(mout);
rewrite(mout);
For i:= 1 To n Do
Begin
For j:=1 To M Do
read(x[i,j]);
readln;
end;
For i := 1 to n do
Begin
For j := 1 to m do write(mout, x[i,j]:5);
writeln(mout)
End;
writeln(mout);
max := x[1,1];
For i:= 1 to n do
for j:= 1 to m do
if x[i,j] > max then max := x[i,j];
writeln(mout, 'Groesstes ist ',max);
writeln(mout);
writeln(mout, 'done.');
close(mout);
readln;
end.
aber da fehlen ja die type konstruktionen und das unterprogramm
hat vllt jmd einen lösungsansatz oder vorschlag
?
achja ich programmiere alles in Freepascal
danke im vorraus
gruss sascha
dieser Matrix an einen Ausgabeparameter übergibt.Welche Typdeklarationen sind hier notwendig?
nun habe ich schon folgendes getestet:
ich habe probiert in der einen unit, die matrix zu initalisieren und sie in eine input.txt gespeichert und dann in hauptprogramm habe ich einfach die zahlen aus der input.txt in die output.txt einlesen lassen.
ich bin nun soweit, dass ich mein programm habe, allerdings ohne unterprogramm:
PROGRAM Matrix(input, output, mout);
const
n=5; m=5;
var
x: Array[1..n] of Array[1..m] of integer;
i,j,max : integer;
mout : text;
begin
assign(mout, 'output.txt');
reset(mout);
rewrite(mout);
For i:= 1 To n Do
Begin
For j:=1 To M Do
read(x[i,j]);
readln;
end;
For i := 1 to n do
Begin
For j := 1 to m do write(mout, x[i,j]:5);
writeln(mout)
End;
writeln(mout);
max := x[1,1];
For i:= 1 to n do
for j:= 1 to m do
if x[i,j] > max then max := x[i,j];
writeln(mout, 'Groesstes ist ',max);
writeln(mout);
writeln(mout, 'done.');
close(mout);
readln;
end.
aber da fehlen ja die type konstruktionen und das unterprogramm

hat vllt jmd einen lösungsansatz oder vorschlag

achja ich programmiere alles in Freepascal
danke im vorraus
gruss sascha