我看到原代码的想法是:
就不能在计算器上面先算一下?
和着我每次输入的时候电脑都要把能先算好的东西再算一下是吧?
然后比如我算个10w以下的数
我为什么还要去算10w以上的数据啊?
于是
#include<stdio.h>
int main()
{
double i,x;
printf(“你的利润是:”);
scanf("&lf", &i);
if (i<=100000) {
x = i *10;
}
else if (i <= 200000) {
x = 10000+(i-100000)*0.075;
}
else if (i <= 400000) {
x = 17500 + (i - 200000) * 0.05;
}
else if ( i <= 600000) {
x = 27500 + (i - 400000) * 0.03;
}
else if (i <= 1000000) {
x = 30500 + (i - 600000) * 0.015;
}
printf(“提成为:x=%lf\n”, x);
return 0;
}
直接算好