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]