#include604. 圆的面积using namespace std; int main() { int a, b; cin >> a >> b; cout << a + b << endl; return 0; }
#includeconst double pi = 3.14159; int main () { double r; scanf("%lf", &r); printf("A=%.4lfn", pi * r * r); return 0; }
605. 简单乘积
- 浮点数一般用double(精度问题)
- 保留几位小数的时候一般用 scanf / printf 进行输入输出
#include606. 平均数1using namespace std; int main() { int a, b; cin >> a >> b; cout << "PROD = " << a * b << endl; return 0; }
#include607. 平均数2int main () { double a, b; scanf("%lf%lf", &a, &b); printf("MEDIA = %.5lfn", (a * 3.5 + b * 7.5) / 11); return 0; }
#include608. 差#include using namespace std; int main() { double a, b, c; cin >> a >> b >> c; printf("MEDIA = %.1lfn", a * 0.2 + b * 0.3 + c * 0.5); return 0; }
#include609. 工资using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << "DIFERENCA = " << a * b - c * d << endl; return 0; }
#include610. 工资和奖金int main() { int number, hour; double money; scanf("%d%d%lf", &number, &hour, &money); printf("NUMBER = %dnSALARY = U$ %.2lfn", number, money * hour); return 0; }
#include611. 简单计算#include using namespace std; int main() { string name; double x, y; cin >> name >> x >> y; printf("TOTAL = R$ %.2lfn", x + 0.15 * y); return 0; }
#include612. 球的体积#include using namespace std; int main() { int n1, n2, s1, s2; double p1, p2; cin >> n1 >> s1 >> p1; cin >> n2 >> s2 >> p2; printf("VALOR A PAGAR: R$ %.2lfn", s1 * p1 + s2 * p2); return 0; }
#include613. 面积const double pi = 3.14159; int main() { int r; scanf("%d", &r); printf("VOLUME = %.3lfn", 4 / (3.0) * pi * r * r * r); return 0; }
#include614. 最大值const double pi = 3.14159; int main() { double a, b, c; scanf("%lf%lf%lf", &a, &b, &c); printf("TRIANGULO: %.3lfn", a * c / 2); printf("CIRCULO: %.3lfn", pi * c * c); printf("TRAPEZIO: %.3lfn", (a + b) * c / 2); printf("QUADRADO: %.3lfn", b * b); printf("RETANGULO: %.3lfn", a * b); return 0; }
#includeusing namespace std; int main () { int a, b, c, maxnum; cin >> a >> b >> c; maxnum = (a + b + abs(a - b)) / 2; maxnum = (maxnum + c + abs(maxnum - c)) / 2; cout << maxnum << " eh o maior" << endl; return 0; }
615. 油耗max = (a + b + abs(a - b)) / 2;
#include616. 两点间的距离int main() { int s; double oil; scanf("%d %lf", &s, &oil); printf("%.3lf km/ln", s / oil); return 0; }
#include617. 距离#include int main() { double x1, y1, x2, y2; scanf("%lf%lf", &x1, &y1); scanf("%lf%lf", &x2, &y2); printf("%.4lfn", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))); return 0; }
#include618. 燃料消耗using namespace std; int main () { int s; cin >> s; cout << s * 2 << " minutos" << endl; return 0; }
#includeint main() { long long s, t; scanf("%lld %lld", &s, &t); printf("%.3lf",s * t / 12.0); return 0; } // 数据范围(10^18)超过 int(2*10^9)
653. 钞票数据范围1018 int - 2*109
#include654. 时间转换using namespace std; int main() { int money; int cash[] = {100, 50, 20, 10, 5, 2, 1}; cin >> money; cout << money << endl;; for(int i = 0; i < 7; i ++ ) { cout << money / cash[i] << " nota(s) de R$ " << cash[i] << ",00" << endl; money -= (money / cash[i]) * cash[i]; } return 0; }
#include655. 天数转换using namespace std; int main() { int n; cin >> n; cout << n / 3600 << ":" << n % 3600 / 60 << ":" << n % 60 << endl; return 0; }
#include656. 钞票和硬币using namespace std; int main() { int n; cin >> n; cout << n / 365 << " ano(s)" << endl; cout << n % 365 / 30 << " mes(es)" << endl; cout << n % 365 % 30 << " dia(s)" << endl; return 0; }
#includeint main() { int a[] = {100, 50, 20, 10, 5, 2}; int b[] = {100, 50, 25, 10, 5, 1}; double money; scanf("%lf", &money); int n = money * 100; printf("NOTAS:n"); for(int i = 0; i < 6; i ++ ) { printf("%d nota(s) de R$ %.2lfn", n / (a[i] * 100), (double)a[i]); n -= n / (a[i] * 100) * (a[i] * 100); } printf("MOEDAS:n"); for(int i = 0; i < 6; i ++ ) { printf("%d moeda(s) de R$ %.2lfn", n / b[i], b[i] / 100.0); n -= n / b[i] * b[i]; } return 0; }
其他知识点
| 变量类型 | 变量取值 | 变量空间 | 输入输出类型 |
|---|---|---|---|
| bool | false / true | 1B | |
| char | ‘a’ | 1B | %c |
| int | -231 ~ 231-1 | 4B | %d |
| long long | -263 ~ 263-1 | 8B | %lld |
| float | 6~7 位有效数字 | 4B | %f |
| double | 15~16 位有效数字 | 8B | %lf |
| long double | 18~19 位有效数字 | 16B | %llf |



