Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

HELP! puzzle~

stephkaistephkai Posts: 4Member
Hi!I want to ask some questions;
1.where can I find the top 10 example or as if the top 10 example in this site?
2.I don't know why I can't accumulate the score ? I do the part like this;
begin
res[x,y]:=ch;
write(ch);
gotoxy(1,20);
writeln('Score: ',score);
if (ch='res=ans') then
nscore:=score +100;
if (ch<>'res=ans') then;
nscore:=score - 100;
if (alreadyans=done) then
nscore:=score+0;
gotoxy(1,20);
writeln('Your score : ', score);
gotoxy(scrx,scry);
end;
CAn anyone help me?

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hi!I want to ask some questions;
    : 1.where can I find the top 10 example or as if the top 10 example in this site?
    : 2.I don't know why I can't accumulate the score ? I do the part like this;
    : begin
    : res[x,y]:=ch;
    : write(ch);
    : gotoxy(1,20);
    : writeln('Score: ',score);
    : if (ch='res=ans') then
    : nscore:=score +100;
    : if (ch<>'res=ans') then;
    : nscore:=score - 100;
    : if (alreadyans=done) then
    : nscore:=score+0;
    : gotoxy(1,20);
    : writeln('Your score : ', score);
    : gotoxy(scrx,scry);
    : end;
    : CAn anyone help me?
    :
    Here is an example of a top 10 code using the bubble sort algorithm:
    [code]
    type
    TPerson = record
    Name: string;
    Score: integer;
    end;
    TTopTen = array[1..10] of TPerson
    var
    TopTen: TTopTen;
    Temp: TPerson;
    i, j: integer;
    begin
    for i := 1 to 10 do
    for j := 1 to 9 do
    if TopTen[j].Score < TopTen[j+1].Score then
    begin { jth person has lower score than j+1-th person, swap them }
    Temp := TopTen[j];
    TopTen[j] := TopTen[j+1];
    TopTen[j+1] := Temp
    end;
    { Display scores }
    for i := 1 to 10 do
    writeln(TopTen[i].Person, ' ',TopTen[i].Score);
    end;
    [/code]
    If you want to add someone to the top ten, check if his score is higher than the 10th place and replace the 10th place with the new name and score.
    This code can be easily changed to remove the records.

    As for the accumulation code you posted, I cannot make heads or tails from it. So I cannot help you there.
Sign In or Register to comment.