C++信息学奥赛一本通-第一部分-基础一-第2章-第2节
2067 圆-Π的7位背诵
#include <iostream>
using namespace std;
#define PI 3.1415926
int main() {
double r;
cin >> r;
double diameter = r * 2;
double perimeter = r * PI * 2;
double aera = r * r * PI;
printf("%.4f %.4f %.4f", diameter, perimeter, aera);
}
2068 鸡兔同笼-计算差值
#include <iostream>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
int b = (y - (x*2))/2;
int a = x - b;
cout << a << " " << b;
}
1011 甲流疫情死亡率
#include <iostream>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
double result = b / a * 100;
printf("%.3f%%", result);
}
1012 计算多项式的值-算法导论-霍纳法则
这题暴力我觉得没意思,正好对算法导论的多项式算法还有印象
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double x, coefficient[4];
cin >> x >> coefficient[0] >> coefficient[1] >> coefficient[2] >> coefficient[3];
double sum;
for (int i = 0; i < 4; i++) {
sum += coefficient[3 - i] * pow(x, i);
}
printf("%.7f", sum);
}
1013 温度表达转化
#include <iostream>
using namespace std;
int main() {
double f;
cin >> f;
double c = 5.0 * (f - 32) / 9.0;
printf("%.5f", c);
}
1014 与圆相关的计算-和2067的区别就是指定了pi的位数
#include <iostream>
using namespace std;
#define PI 3.14159
int main() {
double r;
cin >> r;
double diameter = r * 2;
double perimeter = r * PI * 2;
double aera = r * r * PI;
printf("%.4f %.4f %.4f", diameter, perimeter, aera);
}
1015 计算并联电阻的阻值
#include <iostream>
using namespace std;
int main() {
double r1, r2;
cin >> r1 >> r2;
double r = 1.0 / (1.0 / r1 + 1.0 / r2);
printf("%.2f", r);
}

被折叠的 条评论
为什么被折叠?



