映画館の 3 件の注文が orders に入っています。それぞれ映画の名前、チケットの枚数、値段を持っています。Up: 2 x 9 = 18 のように注文ごとに 1 行出力し、その金額を total に足しましょう。最後の Total: の行はもう書いてあります。
Up: 2 x 9 = 18 Coco: 3 x 8 = 24 Wall-E: 1 x 12 = 12 Total: 54
#include <stdio.h>
struct Order {
char film[20];
int tickets;
int price;
};
int main(void) {
struct Order orders[] = {
{"Up", 2, 9},
{"Coco", 3, 8},
{"Wall-E", 1, 12}
};
int total = 0;
for (int i = 0; i < 3; i++) {
// ここにコードを書く:この注文の金額を計算し、1 行出力して、total に足す
}
printf("Total: %d\n", total);
return 0;
}
実行すると例で試せます。よさそうなら提出しましょう。