从给定的销售价格和C ++中的损益百分比中查找成本价
考虑我们有售价,并给出了损益的百分比。我们必须找到产品的成本价。公式如下-
$$Cost\:价格=\frac{卖出价格*100}{100+百分比\:利润}$$
$$Cost\:价格=\frac{卖出价格*100}{100+百分比\:亏损}$$
示例
#include<iostream>
using namespace std;
float priceWhenProfit(int sellPrice, int profit) {
return (sellPrice * 100.0) / (100 + profit);
}
float priceWhenLoss(int sellPrice, int loss) {
return (sellPrice * 100.0) / (100 - loss);
}
int main() {
int SP, profit, loss;
SP = 1020;
profit = 20;
cout << "Cost Price When Profit: " << priceWhenProfit(SP, profit) << endl;
SP = 900;
loss = 10;
cout << "Cost Price When loss: " << priceWhenLoss(SP, loss) << endl;
}输出结果
Cost Price When Profit: 850 Cost Price When loss: 1000
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短