Autor Beitrag
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mi 12.05.04 15:34 
Hi

wie definiere ich am besten ein 2-dimensionales dynamisches array? wenn ich mich recht erinnere, gibt es da ja zwei möglichkeiten:

ausblenden Quelltext
1:
2:
3:
a: array[0..0, 0..0] of integer;
// oder
b: array of array of integer;


bei beiden habe ich das problem: wie verändere ich die größe? bei nem 1-dimensionalen array kann ich das ja über setlength(a, 20) erledigen. nur wie geht das mit nem mehr-dimensionalen array?

kann mir da jemand weiter helfen?

gruß
mikeC

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Mi 12.05.04 15:43 
Hi.

Es gibt nur diese möglichkeit für dyn-arrays:

ausblenden Delphi-Quelltext
1:
b: array of array of integer;					


und mit..setlength(a, 20, 40);...kannst du die andere dimension auch noch setzen :wink:

_________________
mfg.
mâximôv
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mi 12.05.04 16:21 
Hallo,

oder

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
b: array of array of integer;

..
SetLength(b, 3);
SetLength(b[0], 10);
SetLength(b[1], 25);
SetLength(b[2], 5);
...

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 12.05.04 22:08 
Hallo!

In den Tutorials hier habe ich auch eines über Arrays geschrieben. Kannst ja mal schauen, ob Du dort noch etwas nützliches findest!

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Mi 12.05.04 23:04 
Mike_C hat folgendes geschrieben:
Hi

wie definiere ich am besten ein 2-dimensionales dynamisches array? wenn ich mich recht erinnere, gibt es da ja zwei möglichkeiten:

ausblenden Quelltext
1:
2:
3:
a: array[0..0, 0..0] of integer;
// oder
b: array of array of integer;

...


Das fällt mir jetzt erst auf: array[0..0, 0..0] :D ...is'n guter delphi joke! muss ich mir merken.

_________________
mfg.
mâximôv