Autor Beitrag
schruppen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22



BeitragVerfasst: Fr 08.07.05 14:57 
Ich will ein Datenarray durchsuchen. 500 werte aufsummieren und einem anderen array zuweisen dann um 500 weiter springen und wieder 500 Werte ausummieren und so weiter.
Das soll so lange gehen, bis eine Bedingung erfüllt ist.
wie kann ich das am besten bewerkstelligen?

Hier der bisherige Code:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
procedure step(var Schritt: integer; array1: array of double);


var
 i,t,y     : integer;



 begin
   t:=Schritt;

     begin
        for i:=0 to  499 do
         sprung[i]:= array1[t+1];
          Y: sum (sprung);
          y: y/500;

         if y < Schwelle then
          begin
           t:= pos + 499;
            for i:= 0 to 499 do
             sprung[i]:= array1[t+1];
              Y: sum (sprung);
              y: y/500;

           // Hier soll er weiter das array durchsuchen, also um 500 weiter Werte 
           // versetzen

         if  y >  Schwelle then
          begin
           vergleich;      // Aufruf einer anderen Prozedur
          end;

 end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconChristian S.: Topic aus Sonstiges verschoben am Fr 08.07.2005 um 16:15
Moderiert von user profile iconGausi: Topic aus Algorithmen, Optimierung und Assembler verschoben am Sa 09.07.2005 um 01:29
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 08.07.05 15:47 
Moin!

Sorry, weder deine Beschreibung noch dein Code lassen mich dein "Problem" verstehen... :gruebel:

Vielleicht erklärst du das nochmal etwas anders?

cu
Narses
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 08.07.05 16:11 
Die repeat..until-Schleife ist dir aber bekannt, oder? Ich würde deine for-Schleife in eine solche packen, und als Abbruchbedingung das y>Schwelle setzen. Das sollte dann hinkommen.

_________________
We are, we were and will not be.
schruppen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22



BeitragVerfasst: Fr 08.07.05 19:40 
Also so in der Art?
repeat until y > Schwelle
for...
Meinst du das ?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 08.07.05 20:01 
Grobe Syntax der repeat-until-Schleife:
ausblenden Delphi-Quelltext
1:
2:
3:
repeat
  {machwas}
until {Bedingung}

Dein "machwas" wäre im wesentlichen die for-Schleife von 1 bis 499 oder so.

Ich empfehle aber einen Blick in ein Anfänger-Tutorial.

_________________
We are, we were and will not be.