Einzelnen Beitrag anzeigen
Alt 21.06.03, 13:54   #6 (permalink)
blue
 
Registriert seit: 10.03.03
blue Leistung: Facit NTK
Likes: 0
Standard

und hier hab ich es mal in object-pascal geschrieben:
Code:
var
     min,max,t,z,v:Integer;
     a,b: string;
begin
  a := '';
  b := '';
  Listbox1.Items.Clear;
  min := strtoint(edit1.Text);
  max := strtoint(edit2.Text)+1;
  for z := min to max do
  begin
    t := 2;
    while (z mod t <> 0) AND (t < z) do t := t+1;
    if z = t then
    begin
      if a = '' then a := inttostr(z) else
      if b = '' then b := inttostr(z) else
      begin
        v := strtoint(b);
        if strtoint(a)+2 = strtoint(b) then listbox1.Items.Add(a+' - '+b);
        a := inttostr(z);
        if v+2 = strtoint(a) then  listbox1.Items.Add(inttostr(v)+' - '+a);
        b := '';
      end;
    end;
  end;
end;
[Edit] Shit hab bei der Aufgabenstellung was überlesen... werds ausbessern :-D[/EDIT]
...
[EDIT]Habs ausgebessert.[/EDIT]
blue ist offline   Mit Zitat antworten
 

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61