C++入门同步记录#3

#include<iostream>
using namespace std;
int main() {
    int ans1;
    char ans2;
    ans1 = 'M' - 'A' + 1;
    ans2 = 33;
    cout << ans1 << endl;
    cout << ans2 << endl;
    return 0;
}

/*#include<iostream>
#include<cmath>
using namespace std;
int main() {
    int r1 = 4, r2 = 10;
    const double PI = 3.141593;
    double v1, v2;
    v1 = (4.0 / 3) * PI * pow(r1, 3);
    v2 = (4.0 / 3) * PI * pow(r2, 3);
    int r3;
    r3 = pow(v1 + v2, 1.0 / 3);
    cout << r3 <<endl;
    return 0;
}*/
#include<iostream>
#include<cmath>
using namespace std;
#define PI 3.141593
int main() {
    int r1 = 4, r2 = 10;
    double V;
    int l;
    V = 4.0 / 3 * PI * (pow(r1, 3) + pow(r2, 3));
    l = pow(V, 1.0 / 3);
    cout << l << endl;
    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int main() {
    double a = 1, b = -100, c = 2400;
    double delta, ans;
    delta = pow(b, 2) - 4 * a * c;
    ans = (-b + sqrt(delta)) / (2 * a); // 因为题目要求定价小, 也就是减价大
    //当有两个x符合要求时, 尽量使 x更大, 即用+ 而不用-
    cout << 110 - int(ans + 0.5) << endl;
    return 0;
}

#include<iostream>
using namespace std;
int main() {
    int t, n;//每个人的苹果数量和人数
    cin >> t >> n;
    cout << t * n << endl;
    return 0;
}


#include<iostream>
using namespace std;
int main() {
    char ch, ans;
    cin >> ch;
    ans = ch - 'a' + 'A';
    cout << ans;
    return 0;
}

#include<iostream>
using namespace std;
int main() {
    double p;
    int q, a, b, c, d;//转换后的四位数和原来的四位数字
    cin >> p;
    q = int (p * 10);
    a = q / 1000; // 千位
    b = q / 100 % 10; // 百位
    c = q / 10 % 10; // 十位
    d = q % 10; // 个位
    cout << d << '.' << c << b << a << endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值