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: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92:
| procedure TForm1.Button1Click(Sender: TObject); var a, b, c, d, e: integer; begin randomize; a:=Random(100)+1; b:=Random(100)+1; c:=Random(100)+1; d:=Random(100)+1; e:=Random(100)+1;
ListBox1.Items.Add(IntToStr(a)); ListBox1.Items.Add(IntToStr(b)); ListBox1.Items.Add(IntToStr(c)); ListBox1.Items.Add(IntToStr(d)); ListBox1.Items.Add(IntToStr(e));
end;
procedure TForm1.Button4Click(Sender: TObject); var min,max,min2,min3,min4,positi,posit,positio,j,g,i,f,h,posi,pos: integer; begin with listbox1 do begin min:=StrToInt(Items[0]); Pos:=0; for i:=1 to Items.count-1 do if StrToInt(Items[i]) <= min then begin min:=StrToInt(Items[i]) ; pos:=i; end; Items[i]:=Items[0]; Items[0]:=inttostr(min); Items.Delete(pos); end;
with listbox1 do begin min2:=Strtoint(items[1]); posit:=1; for g:=2 to items.count-1 do if strtoint(items[g]) <= min2 then begin min2:=StrToInt(Items[g]); posit:=g; end; Items[g]:=Items[1]; Items[1]:=inttostr(min2); Items.Delete(posit); end; with listbox1 do begin min3:=Strtoint(items[2]); positi:=2; for h:=3 to items.count-1 do if strtoint(items[h]) <= min3 then begin min3:=StrToInt(Items[h]); positi:=h; end; Items[h]:=Items[2]; Items[2]:=inttostr(min3); Items.Delete(positi); end; with listbox1 do begin min4:=Strtoint(items[3]); positio:=3; for j:=4 to items.count-1 do if strtoint(items[j]) <= min4 then begin min4:=StrToInt(Items[j]); positio:=j; end; Items[j]:=Items[3]; Items[3]:=inttostr(min4); Items.Delete(positio); end; with listbox1 do begin max:=strToInt(Items[0]); posi:=0; for f:=0 to Items.count-1 do if strtoint(items[f]) >= max then begin max:=StrToInt(Items[f]); posi:=f; end; Items.Delete(posi); Items.Add(Inttostr(max)) end; end; |