本文共 1105 字,大约阅读时间需要 3 分钟。
Mooc 课程:程序设计基础——发现计算之美
李骏扬 、魏海坤 、仰燕兰 、朱蔚萍 、杨万扣 网址:#includeusing 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#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:
ALL RIGHTS RESERVED © 2020 Teddy van Jerry
欢迎转载,转载请注明出处。