在C ++中从给定的利润百分比和成本中查找售价
考虑我们有售价,并给出了损益的百分比。我们必须找到产品的成本价。公式如下-
$$CostPrice=\frac{卖出价格*100}{100+利润百分比}$$$$CostPrice=\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
热门推荐
9 孙媳妇祝福语简短
10 朋友祝福语两字简短
11 祝福语老人简短话语
12 前程祝福语简短暖心
13 离别祝福语简短送同事
14 庆祝国家的祝福语简短
15 送花简短有内涵祝福语
16 上级买车祝福语大全简短
17 双节祝福语简短英文
18 祝朋友祝福语简短好看