程序从C ++中以给定比率查找每种类型的硬币数量
为此,我们将为您提供全部金额以及1卢比-50帕斯卡-25帕斯卡硬币的比率。我们的任务是找到袋子中每种硬币的总数。
示例
#include <bits/stdc++.h>
using namespace std;
//计算硬币数量
int coin(int totalRupees, int X, int Y, int Z) {
float one = 0, fifty = 0, twentyfive = 0, result = 0, total = 0;
one = X * 1;
fifty = ((Y * 1) / 2.0);
twentyfive = ((Z * 1) / 4.0);
total = one + fifty + twentyfive;
result = ((totalRupees) / total);
return result;
}
int main() {
int totalRupees = 1800;
int X = 1, Y = 2, Z = 4;
int Rupees = coin(totalRupees, X, Y, Z);
cout << "1 rupess coins = " << Rupees * 1 << endl;
cout << "50 paisa coins = " << Rupees * 2 << endl;
cout << "25 paisa coins = " << Rupees * 4 << endl;
return 0;
}输出结果
1 rupess coins = 600 50 paisa coins = 1200 25 paisa coins = 2400
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短