0

私のラボでは、値の目的のステートメントに続く列に出力値を表示する必要があります。

私が必要とするものの例。

Amount of adult tickets:                      16
Amount of children tickets:                   12
Revenue from ticket sales:                    $140.22

私はsetwのように使用しようとしています

cout << "Amount of adult tickets: " << setw(15) << ticketsAdult` << endl;
cout << "Amount of children tickets: " << setw(15) < ticketsChildren << endl;

setw をこれに使用するのは間違っているか、通常は次のような結果になるため、間違って使用していると思います

Amount of adult tickets:                    16
Amount of children tickets:                    12

それぞれの前の「Amount of ...」ステートメントの長さに関係なく、例のように右の値をすべて整列させるにはどうすればよいですか?

4

2 に答える 2