为此,我们将为您提供全部金额以及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