Autor Beitrag
BigBossMan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 17.08.04 19:20 
Hallo Leute !

Wie programmiert man eine Schleife die sich um 1 erhöht ?

Vielen Dank im voraus

Mfg
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Di 17.08.04 19:22 
Nicht etwa so?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 0 to 10 do
begin
  {...}
end;

Eine Schleife die bei 0 anfängt und solange sich um eins erhöhend läuft, bis die 10 erreicht ist.

raziel

_________________
JSXGraph
BigBossMan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 17.08.04 19:26 
raziel hat folgendes geschrieben:
Nicht etwa so?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 0 to 10 do
begin
  {...}
end;

Eine Schleife die bei 0 anfängt und solange sich um eins erhöhend läuft, bis die 10 erreicht ist.

raziel


Leider nein. Die Schleife soll nicht bis 10 hochzählen, sondern sich nur um 1 erhöhen.

Mfg
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Di 17.08.04 19:28 
Dann versteh ich nicht, was Du meinst... :gruebel: -> Ein paar Infos mehr, bitte...

_________________
JSXGraph
BigBossMan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 17.08.04 19:36 
raziel hat folgendes geschrieben:
Dann versteh ich nicht, was Du meinst... :gruebel: -> Ein paar Infos mehr, bitte...


Mehr Infos habe ich auch nicht. Vieleicht braucht man da zu auch keine Schleife. Was bedeute die Funktion
ausblenden Quelltext
1:
Inc(); ?					


Mfg
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Di 17.08.04 19:41 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
//Inc erhöht die Variable eineintegervariable um 1
Inc(eineintegervariable);
//Inc erhöht die Variable eineintegervariable um 8
Inc(eineintegervariable, 8);


Drück in der Delphi-IDE mal F1... :roll:

raziel

_________________
JSXGraph
heinze
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 112

XP
D4 Prof
BeitragVerfasst: Di 17.08.04 19:52 
rekursion?
oder vileicht etwas hiervon :

ausblenden Delphi-Quelltext
1:
2:
3:
repeat
schleife:=schleife +1;
until weltunergang


auch wahlweise mit while möglich
Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.
Gothicware
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 77

Win 98, Win 2000, Win XP, BeOs-R5, Zeta 1.0(war nicht gut, also verkauft), KnoppiX, VM-Ware
D4 Client/Server, Turbo Basic, QBasic, Atari-Basic
BeitragVerfasst: Mi 18.08.04 23:03 
Wenn man
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
i := random(High(Integer) -1) +1;
for i := i to i +1 do
     begin
     //mach was mit i...
     end;

nimmt, hat man ne schleife, die sich genau einmal erhöht, egal wie der Wert i vorher war. :lol:

Ansonsten verdoppelt man die Funktion einfach:

ausblenden Delphi-Quelltext
1:
2:
3:
machwasmiti(i);
inc(i);
machwasmiti(i);

sieht zwar nicht schön aus, aber "it works".

Aber ich verstehe, (andere wahrscheinlich auch nicht, was das für nen Sinn haben sol, ne schleife die sich nur um 1 erhöht.)

Oder der Meint ne Doppelte Schleife.

ausblenden Delphi-Quelltext
1:
2:
3:
for schleife1 := 1 to 10 do
     for schleife2 := 0 to schleife1 do
          machwas(schleife1,schleife2);

Damit erhöht sich das Ende der schleife2 immer um 1.
Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.