2021-07-11-C++学习笔记

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

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;
}
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

文艺晓萱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值