【条件判断】

知识框架

No.0 筑基

请先学习下知识点,道友!
题目知识点大部分来源于此:

题目例题大部分来源于此:

No.1 条件判断

题目来源:PTA-L1-031 到底是不是太胖了

题目描述:
在这里插入图片描述

题目思路:

题目代码:

#include <stdio.h>
#include <math.h>
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		float h, w;
		scanf("%f %f", &h, &w);
		float stan = (h - 100) * 0.9 * 2;
		if (fabs(w - stan) < stan * 0.1)
			printf("You are wan mei!\n");
		else if (stan < w)
			printf("You are tai pang le!\n");
		else
			printf("You are tai shou le!\n");
	}

	return 0;
}

题目来源:PTA-L1-063 吃鱼还是吃肉

题目描述:
在这里插入图片描述

题目思路:

题目代码:

#include <iostream>

using namespace std;

int main()
{
    int n;
    int sex,height,weight;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>sex>>height>>weight;
        if(sex==0){
            if(height<129){
                cout<<"duo chi yu! ";
            }else if(height==129){
              cout<<"wan mei! ";
            }else{cout<<"ni li hai! ";}

                            //显示旁的
            if(weight<25){
                cout<<"duo chi rou!"<<endl;
            }else if(weight==25){
                cout<<"wan mei!"<<endl;
            }else{
            cout<<"shao chi rou!"<<endl;
            }
        }else{
                        if(height<130){
                cout<<"duo chi yu! ";
            }else if(height==130){
              cout<<"wan mei! ";
            }else{cout<<"ni li hai! ";}

                            //显示旁的
            if(weight<27){
                cout<<"duo chi rou!"<<endl;
            }else if(weight==27){
                cout<<"wan mei!"<<endl;
            }else{
            cout<<"shao chi rou!"<<endl;
            }

        }

    }
    return 0;
}

题目来源:PTA-L1-069 胎压监测

题目描述:
在这里插入图片描述

题目思路:

题目代码:

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define N 10010
int n,m,k,g,d;
int x,y,z;
char ch;
string str;
vector<int>v[N];

int main() {
    int a1,a2,a3,a4;
    cin>>a1>>a2>>a3>>a4>>g>>d;
    int maxx=0;
    maxx=max({a1,a2,a3,a4});
    int count=0;
    int flag1=0,flag2=0,flag3=0,flag4=0;
    if(a1<g||(maxx-a1)>d)count++;flag1=1;
    if(a2<g||(maxx-a2)>d)count++;flag2=1;
    if(a3<g||(maxx-a3)>d)count++;flag3=1;
    if(a4<g||(maxx-a4)>d)count++;flag4=1;
    if(count==0)cout<<"Normal"<<endl;
    else if(count==1){
        if(flag1==1){
            cout<<"Warning: please check #1!"<<endl;
        }else if(flag2==1){
            cout<<"Warning: please check #2!"<<endl;
        }else if(flag3==1){
            cout<<"Warning: please check #3!"<<endl;

        }else{
            cout<<"Warning: please check #4!"<<endl;
        }
    }else{
        cout<<"Warning: please check all the tires!"<<endl;
    }

	return 0;
}

题目来源:PTA-L1-077 大笨钟的心情

题目描述:
在这里插入图片描述

题目思路:

题目代码:

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define N 10010
int n,m,k,g,d;
int x,y,z;
char ch;
string str;
vector<int>v[N];

int main() {
    int num[24]={0};
    for(int i=0;i<24;i++){
        cin>>num[i];
    }
    for(int i=0; ;i++){
        cin>>x;
        if(x<0 || x>23)break;
        if(num[x]>50)cout<<num[x]<<" Yes"<<endl;
        else cout<<num[x]<<" No"<<endl;
    }
  
	return 0;
}

题目来源:PTA-L1-083 谁能进图书馆

题目描述:
在这里插入图片描述

题目思路:

题目代码:

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define N 505
int n,m,k,g,d;
int x,y,z;
char ch;
string str;
vector<int>v[N];
#define PII pair<int,int>


	
	
int main()
{
    int jin,pei,year1,year2;
    cin>>jin>>pei>>year1>>year2;
    if(year1<jin&&year2<pei){
        cout<<year1<<"-N ";
    }else{
        cout<<year1<<"-Y ";
    }
    if(year2<jin&&year1<pei){
        cout<<year2<<"-N";
    }else{
        cout<<year2<<"-Y";
    }
    cout<<endl;
    
    
    if(year1<jin&&year2>=jin&&year2<pei){
        cout<<2<<": huan ying ru guan"<<endl;
    }
    if(year2<jin&&year1>=jin&&year1<pei){
        cout<<1<<": huan ying ru guan"<<endl;
    }
    if(year1<jin&&year2<jin){
        cout<<"zhang da zai lai ba"<<endl;
    }
    if(year1>=jin&&year2>=jin){
        cout<<"huan ying ru guan"<<endl;
    }
    if(year1<jin&&year2>=pei){
        cout<<"qing "<<2<<" zhao gu hao "<<1<<endl;
    }
    if(year2<jin&&year1>=pei){
        cout<<"qing "<<1<<" zhao gu hao "<<2<<endl;
    }
    
	
    
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值