これを以前に投稿しましたが、コーディングの試みを示さなかったため閉鎖されました。ここに質問があります。
SECTIONS
$160 = section 1
$220 = section 2
$280 = section 3
$350 = section 4
$425 = section 5
それぞれが衣装の全費用を支払った不特定多数のマスカレードの名前とそれぞれが支払った金額を入力として受け入れる擬似コードを開発します。
マスカレードは、バンドの5つのセクションのいずれかで衣装を購入した可能性があります. アルゴリズムは、マスカレーダーがコスチュームに支払った金額に基づいて、マスカレーダーがプレイするセクションを決定する必要があります。アルゴリズムは、各セクションで衣装を購入したマスカレードの数も決定する必要があります.
人の名前と支払ったセクションを印刷する必要があります。セクションのリストと各セクションでプレーするために登録された合計人数も、各セクションで支払われた合計金額とともに印刷する必要があります。
これが私の試みです: *これは Pascal でプログラムされていることに注意してください。修正と仕上げの助けが必要です。助けてください、もう一度感謝します。
program Masqueraders;
uses
WinCrt; { Allows Writeln, Readln, cursor movement, etc. }
const
MAX = 5; {this determine the amount of masquarader entered}
Type
listname = Array[1..MAX] of string;
listsect = Array[1..MAX] of string;
var
names : listname;
sections : listsect;
i, amount, TotalMas, TotalAmt, c1, c2, c3, c4, c5, amt1, amt2, amt3, amt4, amt5 : integer;
begin
amount := 1;
while amount <> 0 do
begin
i := i + 1;
readln(names[i]);
readln(amount);
if(amount = 160) then
begin
c1 := c1 + 1; {Count the number of persons for section 1}
amt1 := amt1 + amount; {accumulate the amount for section 1}
sections[i] := 'Section 1';
end;
if(amount = 220) then
begin
c2 := c2 + 1; {Count the number of persons for section 1}
amt2 := amt2 + amount; {accumulate the amount for section 1}
sections[i] := 'Section 2';
end; {end the IF for section 2}
if(amount = 280) then
begin
c3 := c3 + 1; {Count the number of persons for section 1}
amt3 := amt3 + amount; {accumulate the amount for section 1}
sections[i] := 'Section 3';
end; {end the IF for section 3}
if(amount = 350) then
begin
c4 := c4 + 1;
amt4 := amt4 + amount;
sections[i] := 'Section4';
end; {end If for section 4}
if (amount = 425) then
begin
c5 := c5 + 1;
amt5 := amt5 + amount;
sections[i] := 'Section5';
end;{end the while loop}
TotalMas := c1 + c2 + c3;
TotalAmt := amt1 + amt2 + amt3;
writeln('Name Section'); {Heading for the output}
for i := 1 to MAX do
begin
write(names[i]);
writeln(' ',sections[i]);
end;
writeln('Section 1: ');
write('Masquader: ', c1);
write('Amount: ', amt1);
writeln('Total Number of Masquarader: ', TotalMas);
writeln('Total Amount Paid by masquarader: ', TotalAmt);
終わり; 終わり。
つまり、不特定多数の人を受け入れ、入力した金額に基づいてそれぞれのセクションに割り当て、各セクションの人数を計算する必要があります。これは私の現在の出力です:
名前 John Money=160 セクション 1
名前 Keith Money=220 セクション ジョン
これは私が欲しいものです:
名前 John Money=160 Section1
名前 Keith Money=220 Section2