C++分支题目2

写评语

#include<iostream>
using namespace std;
int main()
{
    int score;
    cin>>score;
    if(score>=90)
    {
        cout<<"Excellent";
    }
    else if(score>=80&&score<90)
    {
        cout<<"Good";
    }
    else if(score>=60&&score<80)
    {
        cout<<"Pass";
    }
    else if(score<60)
    {
        cout<<"Fail";
    }
    return 0;
}

分配任务

#include<iostream>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x+y<10)
    {
        cout<<"water";
    }
    else if(x+y>10&&y>x)
    {
        cout<<"tree";
    }
    else if(x+y>10&&x>y)
    {
        cout<<"tea";
    }
    return 0;
}

闰年判断

#include<iostream>
#include<iomanip> 
using namespace std;
int main()
{
    int nian;
    cin>>nian;
    if(nian%4==0&&nian%100!=0||nian%400==0)
    {
        cout<<"yes";
    }
    else
    {
        cout<<"no";
    }
    return 0;
}

判断3的倍数

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%3=0)
    {
        cout<<"yes";
    }
    else
    {
        cout<<"no";
    }
    return 0;
}

超市卖电池

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=10)
    {
        cout<<fixed<<srtprecision(1)<<0.1*n*2;
    }
    else
    {
        cout<<fixed<<srtprecision(1)<<0.1*n*2*0.9;
    }
    return 0;
}

水果批发

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=100)
    {
        cout<<n*2;
    }
    else
    {
        cout<<100*2+(n-100)*1;
    }
    return 0;
}

成绩

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=60)
    {
        cout<<"pass!";
    }
    else
    {
        cout<<"sorry!";
    }
    return 0;
}

行李托运费

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<=20)
    {
        cout<<fixed<<setprecision(2)<<n*1.68;
    }
    else
    {
        cout<<fixed<<setprecision(2)<<n*1.98;
    }
    return 0;
}

大数的平方

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<a*a;
    }
    else if(b>a)
    {
        cout<<b*b;
    }
    return 0;
}

计算考试需要的教室

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int z,r;
    cin>>z>>r;
    if(z%r==0)
    {
        cout<<z/r;
    }
    else
    {
        cout<<z/r+1; 
    }
    return 0;
}

预算够吗

#include<iostream>
using namespace std;
int main()
{
    int n,a,b,c,i;
    cout<<"1 预算多少?2 原材料多少元/万元?3 工资多少元/万元? 4 其他多少元/万元?"; 
    cin>>n>>a>>b>>c;
    if(n<a+b+c)
    {
        i=a+b+c-n;
        cout<<"多出"<<i<<" "<<"NO";
    }
    else
    {
        i=n-(a+b+c);
        cout<<"剩余"<<i<<" "<<"YES";
    }
    
    
    return 0;
}

是不是正方形

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"Y"<<endl<<a*b;
    }
    else
    {
        cout<<"N"<<endl<<a*b;
    }
    return 0;
}

是两位的偶数吗

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n/100==0&&n/10!=0&&n%2==0);
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    return 0;
}

游乐设施

#include<iostream>
using namespace std;
int main()
{
    float a,b;
    cin>>a>>b;
    if(a>=60&&b<60);
    {
        cout<<"green";
    }
    else if(a<60&&b>=60)
    {
        cout<<"green";
    }
    else
    {
        cout<<"red";
    }
    
    return 0;
}

是否含有数字5

#include<iostream>
using namespace std;
int main()
{
    int n,g,s,b,c,w;
    cin>>n;
    g=n%10;
    s=n/10%10;
    b=n/100%10;
    c=n/1000%10;
    w=n/10000%10;
    if(g==5||s==5||b==5||c==5||w==5)
    {
        cout<<g+s+b+c+w;
    }
    else
    {
        cout<<n;
    }
    return 0;
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值