C++信息学奥赛一本通-第一部分-基础一-第2章-第2节

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);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值