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

本文介绍如何修复并完善一个手机运营商的促销代码,通过输入的倍增器正确调整用户的网速。提供了一个示例输入和输出,以及完成的`promotion`函数调用,确保了带宽在促销前后计算的准确性。

You operate a mobile provider running a promotion that multiplies a user’s internet bandwidth.
Fix the program by completing the function and calling it, so that the given megabyte outputs before and after the promotion work correctly.
The multiplier is taken as input inside the multiplier function.

Sample Input
5
2

Sample Output
Before the promotion: 5
After the promotion: 10

Explanation
The first input is the count of megabytes, the second is multiplier.
The first outputted line represents the count of megabytes before the function-multiplier call, and the second one - after.

//my code
#include <iostream>
using namespace std;
//Created by Liu Chong on 2021/07/15

/*complete the function to multiple the megabytes*/
int promotion(int *m,int n) {
    
    //taking multiplier as input
    int multiplier;
    cin>>multiplier;
    *m=multiplier*n;  

    //cout<<*m<<endl;
    
    
}

int main() {
    //getting initial count of megabytes
    int megabytes;
    cin >> megabytes;
    
    //printing the count of megabytes 
    cout << "Before the promotion: " << megabytes << endl;
    
    //complete the function call
    
    promotion(&megabytes,megabytes);
    
    //printing the count of megabytes after the promotion
    cout << "After the promotion: " << megabytes<< endl;
    
    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、付费专栏及课程。

余额充值