top 5 list

Im trying to create a simple top 5 list , but im having a problem.

1st the code ..
[b]
var x:array[0..4] of integer;
var i:integer;
begin
memo1.Clear;
x[0] := 100; //student 1 score
x[1] := 300;//student 2 score
x[2] := 100;//student 3 score
x[3] := 600;//student 4 score
x[4] := 400;//student 5 score

for i:=4 downto 0 do begin
while (x[i] > x[i]) do begin
memo1.Lines.Add(inttostr(x[i]));
end;
end;
[b]

For some reason the output is just ... a big space!.
Can anyone help me please ?

Comments

  • : Im trying to create a simple top 5 list , but im having a problem.
    :
    : 1st the code ..
    : [b]
    : var x:array[0..4] of integer;
    : var i:integer;
    : begin
    : memo1.Clear;
    : x[0] := 100; //student 1 score
    : x[1] := 300;//student 2 score
    : x[2] := 100;//student 3 score
    : x[3] := 600;//student 4 score
    : x[4] := 400;//student 5 score
    :
    : for i:=4 downto 0 do begin
    : while (x[i] > x[i]) do begin
    : memo1.Lines.Add(inttostr(x[i]));
    : end;
    : end;
    : [b]
    :
    : For some reason the output is just ... a big space!.
    : Can anyone help me please ?
    :
    x[i] > x[i] is always false, because how can a value be larger than itself. The simplest way to implement a top list, is to implement a sort routine, such as insertion, quick, bubble, selection, etc. sort. This board contains enough examples for sorting codes.
  • : : Im trying to create a simple top 5 list , but im having a problem.
    : :
    : : 1st the code ..
    : : [b]
    : : var x:array[0..4] of integer;
    : : var i:integer;
    : : begin
    : : memo1.Clear;
    : : x[0] := 100; //student 1 score
    : : x[1] := 300;//student 2 score
    : : x[2] := 100;//student 3 score
    : : x[3] := 600;//student 4 score
    : : x[4] := 400;//student 5 score
    : :
    : : for i:=4 downto 0 do begin
    : : while (x[i] > x[i]) do begin
    : : memo1.Lines.Add(inttostr(x[i]));
    : : end;
    : : end;
    : : [b]
    : :
    : : For some reason the output is just ... a big space!.
    : : Can anyone help me please ?
    : :
    : x[i] > x[i] is always false, because how can a value be larger than itself. The simplest way to implement a top list, is to implement a sort routine, such as insertion, quick, bubble, selection, etc. sort. This board contains enough examples for sorting codes.
    :
    Thanks , i think i found what i was looking for.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories