博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【SEU程序设计课笔记】 Mooc - Chapter 3 - 个人所得税/一元二次方程
阅读量:718 次
发布时间:2019-03-21

本文共 1105 字,大约阅读时间需要 3 分钟。

Mooc 课程:程序设计基础——发现计算之美

李骏扬 、魏海坤 、仰燕兰 、朱蔚萍 、杨万扣
网址:


个人所得税

#include 
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:

1

一元二次方程

#include 
#include
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:

2


ALL RIGHTS RESERVED © 2020 Teddy van Jerry

欢迎转载,转载请注明出处。


See also

你可能感兴趣的文章