#include<iostream>
using namespace std;
int main()
{
double income,i;
cout<<“请输入当月利润”<<endl;
cin>>i;
double m1=100000*0.1;
double m2=m1+0.075*100000;
double m3=m2+200000*0.05;
double m4=m3+200000*0.03;
double m5=m4+400000*0.0015;
int c;
if(i=100000)
{
c=0;
}
if(i=200000)
{
c=1;
}
if(i=400000)
{
c=2;
}
if(i=600000)
{
c=4;
}
if(i=100000)
{
c=9;
}
if(i>1000000)
{
c=10;
}
else
{
c=(i/100000.);
}
switch(c)
{
case 0:income=i*0.1;break;
case 1:income=m1+(i-100000)*0.075;break;
case 2:income=m2+(i-200000)*0.05;
case 3:income=m2+(i-200000)*0.05;break;
case 4:income=m3+(i-400000)*0.03;
case 5:income=m3+(i-400000)*0.03;break;
case 6:income=m4+(i-600000)*0.015;
case 7:income=m4+(i-600000)*0.015;
case 8:income=m4+(i-600000)*0.015;
case 9:income=m4+(i-600000)*0.015;break;
case 10:income=m5+(i-1000000)*0.001;break;
}
cout<<“income=”<<income<<endl;
system(“pause”);
return 0;
}
using namespace std;
int main()
{
double income,i;
cout<<“请输入当月利润”<<endl;
cin>>i;
double m1=100000*0.1;
double m2=m1+0.075*100000;
double m3=m2+200000*0.05;
double m4=m3+200000*0.03;
double m5=m4+400000*0.0015;
int c;
if(i=100000)
{
c=0;
}
if(i=200000)
{
c=1;
}
if(i=400000)
{
c=2;
}
if(i=600000)
{
c=4;
}
if(i=100000)
{
c=9;
}
if(i>1000000)
{
c=10;
}
else
{
c=(i/100000.);
}
switch(c)
{
case 0:income=i*0.1;break;
case 1:income=m1+(i-100000)*0.075;break;
case 2:income=m2+(i-200000)*0.05;
case 3:income=m2+(i-200000)*0.05;break;
case 4:income=m3+(i-400000)*0.03;
case 5:income=m3+(i-400000)*0.03;break;
case 6:income=m4+(i-600000)*0.015;
case 7:income=m4+(i-600000)*0.015;
case 8:income=m4+(i-600000)*0.015;
case 9:income=m4+(i-600000)*0.015;break;
case 10:income=m5+(i-1000000)*0.001;break;
}
cout<<“income=”<<income<<endl;
system(“pause”);
return 0;
}
解决方案
20
if (i = 100000)
改成
if (i == 100000)
同理其他的
改成
if (i == 100000)
同理其他的
20
= 是赋值
判断相等用的是 ==
判断相等用的是 ==
5
楼上正解,单个“”=“”的意思是赋值;两个“”==“”的意思是判断能否相等。接分
5
= 和 == 的差异
10
新手易犯错误之一。
所以以后写可以写成if(100000==i)
假如不小心写成了if(100000=i)那是过不了编译的
所以以后写可以写成if(100000==i)
假如不小心写成了if(100000=i)那是过不了编译的
5
这种错误本人以前经常犯~~~半天还找不出来~