Einzelnen Beitrag anzeigen

problemstoffe

Registriert seit: 6. Jun 2007
16 Beiträge
 
#1

Sieb des Eratosthenes: Von Pascal nach R-Pascal

  Alt 3. Mai 2008, 15:57
Muss in Delphi ein Quellcode für das Sieb des E. entwickeln und das ganze dann in ein R-Pascal umschreiben. Das habe ich jetzt mal auf die Beine gestellt. Stimmt das soweit?
Delphi-Quellcode:

 for i := 2 to 100 do zahl[i] := i;
  p := 2;
  while p <= 100 do
  begin
    v := 2;
    while v*p <= 100 do
    begin
      zahl[v*p] := 0;
      v := v+1;
    end;
    i := p+1;
    while (i<=100) and (zahl[i] = 0) do i := i + 1;
    p := i;
  end;
Und das ganze in R-Pascal
Delphi-Quellcode:

for i := 2 to 100 do zahl[i] := i;            
  p := 2;
 M1: If not p <= 100 Then Goto M2;
 begin
     v := 2;
     Goto M1;
   M2: If not v*p <= 100 Then Goto M3;
         begin
            zahl[v*p] := 0;
            Goto M2;
      M3: v := v+1;
       end;
     i := p+1;
      M4: If not (i<=100) and (zahl[i] = 0) Then Goto M5;
       i := i + 1;
          Goto M4;
      M5: p := i;
 end;
Danke euch im Voraus...
  Mit Zitat antworten Zitat