Mooc 课程:程序设计基础——发现计算之美 李骏扬 、魏海坤 、仰燕兰 、朱蔚萍 、杨万扣 网址:https://www.icourse163.org/course/SEU-1003771004
个人所得税
#include <iostream>
using namespace std
;
int main()
{
double n
;
cin
>> n
;
n
-= 60000;
if (n
<= 0)cout
<< 0 << endl
;
else if (n
<= 36000) cout
<< 0.03 * n
<< endl
;
else if (n
<= 144000) cout
<< 0.1 * n
- 2520 << endl
;
else if (n
<= 300000) cout
<< 0.2 * n
- 16920 << endl
;
else if (n
<= 420000) cout
<< 0.25 * n
- 31920 << endl
;
else if (n
<= 660000) cout
<< 0.3 * n
- 52920 << endl
;
else if (n
<= 960000) cout
<< 0.35 * n
- 85920 << endl
;
else cout
<< 0.45 * n
- 181920 << endl
;
return 0;
}
Output:
一元二次方程
#include <iostream>
#include <cmath>
using namespace std
;
int main()
{
double a
, b
, c
;
cin
>> a
>> b
>> c
;
if (a
== 0)
{
if (b
== 0)
{
if (c
== 0) cout
<< "无数组解" << endl
;
else cout
<< "无解" << endl
;
}
else cout
<< "x = " << -c
/ b
<< endl
;
}
else
{
double delta
= b
* b
- 4 * a
* c
;
if (delta
< 0) cout
<< "无解" << endl
;
else cout
<< "x1 = " << (-b
+ sqrt(delta
)) / (2 * a
) << ", x2 = " << (-b
- sqrt(delta
)) / (2 * a
) << endl
;
}
return 0;
}
Output:
ALL RIGHTS RESERVED © 2020 Teddy van Jerry 欢迎转载,转载请注明出处。
See also
Teddy van Jerry 的导航页