You are working on a ticketing system. A ticket costs $10.
The office is running a discount campaign: each group of 5 people is getting a discount, which is determined by the age of the youngest person in the group.
You need to create a program that takes the ages of all 5 people as input and outputs the total price of the tickets.
Sample Input:
55
28
15
38
63
Sample Output:
42.5
The youngest age is 15, so the group gets a 15% discount from the total price, which is $50 - 15% = $42.5
//author:Liu Chong
//2021-07-11-01-06
#include <iostream>
using namespace std;
int main() {
int ages[5];
for (int i = 0; i < 5; ++i) {
cin >> ages[i];
}
/*for(int i=0;i<5;i++){
cout<<ages[i]<<endl;
}*/
//检查输入哪些年龄
double youngest =ages[0];
for(int i = 0;i < 5;i++){
if (ages[i]<youngest)
youngest = ages[i];
}
//cout<<youngest<<endl;
//检查最小的对不对
double discount;
discount=youngest/100;
double money;
money=50-50*discount;
// 求折扣和折扣后的价格
cout << money;
return 0;
}

这是一个C++程序,用于处理一个售票系统中的折扣计算。当一组5人购票时,根据组内最年轻成员的年龄给予折扣。例如,输入年龄分别为55、28、15、38和63时,因为最年轻的成员15岁,所以享受15%的折扣,总票价为42.5美元。程序首先读取5个人的年龄,然后找出最小年龄并计算相应的折扣价。
1437

被折叠的 条评论
为什么被折叠?



