C++语法基础—— 判断语句习题_2——ACwing

AcWing 672. 税

#include<iostream>
using namespace std;
int main()
{
    double num;
    cin >> num;
    double tex;
    if (0 <= num && num <= 2000) {cout << "Isento"; return 0;}
    else if (2000 < num && num <= 3000) {
        tex = (num - 2000) * 0.08;
    }
    else if (3000 < num && num <= 4500) {
        tex = (num - 3000) * 0.18;
        tex += 1000 * 0.08;
    }
    else if (4500 < num){
        tex = (num - 4500) * 0.28;
        tex += 1500 * 0.18;
        tex += 1000 * 0.08;
    } 
    printf("R$ %.2lf", tex);
    return 0;
}

AcWing 663. 简单排序 

 

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int x = a, y = b, z =  c;
    if(x < y) swap(x, y);
    if(x < z) swap(x, z);
    if(y < z) swap(y, z);
    cout << z << endl << y << endl << x << endl << endl;
    cout << a << endl << b << endl << c;
    return 0;
}

 AcWing 658. 一元二次方程公式

 #include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
    double a,b,c;
    cin>>a>>b>>c;
    if(b*b-4*a*c<0||a==0)
    printf("Impossivel calcular");
    else 
    printf("R1 = %.5lf\nR2 = %.5lf",(-b+sqrt(b*b-4*a*c))/(2*a),(-b-sqrt(b*b-4*a*c))/(2*a));
    return 0;
}

AcWing 661. 平均数3 

 

#include <iostream>
using namespace std;
int main()
{
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    double X=(a*2+b*3+c*4+d*1)/10; printf("Media: %.1lf\n",X);
    if(X>=7) cout<<"Aluno aprovado."<<endl;
    else if(X<5)  cout<<"Aluno reprovado."<<endl;
    else if(X>=5&&X<7)
    {
        cout<<"Aluno em exame."<<endl;
        double Y;
        cin>>Y;
        cout<<"Nota do exame: "<<Y<<endl;
        double Z=(X+Y)/2;
        if(Z>=5) cout<<"Aluno aprovado."<<endl;
        else cout<<"Aluno reprovado."<<endl;
        printf("Media final: %.1lf\n",Z);
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

永夜天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值