在本教程中,我们将讨论一个程序,以查找更换混合物后剩余的牛奶量。
让我们假设我们有X升牛奶。由此,将Y升牛奶替换为Y升水本身。Z重复执行相同的过程。我们的任务是找到容器中剩余的最终牛奶量。
找到重复操作之间的值之间的关系,我们找到用于计算Z次操作后的牛奶量的公式为
剩余数量=((XY)/ X)Z * X
#include <bits/stdc++.h> using namespace std; //calculating the final amount of milk float calc_milk(int X, int Y, int Z) { float result = 0.0, result1 = 0.0; result1 = ((X - Y) / (float)X); result = pow(result1, Z); result = result * X; return result; } int main() { int X = 13, Y = 2, Z = 5; cout << calc_milk(X, Y, Z) << endl; return 0; }
5.63884