3124:练21.1 年龄段判断
练21.1 年龄段判断
C语言源码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d",&n);
if( n<=3 )
{
printf("infant\n");
}
else
{
if( n<=12 )
{
printf("child\n");
}
else
{
if( n<=18 )
{
printf("youngster\n");
}
else
{
printf("youth\n");
}
}
}
return 0;
}
C++程序:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
if(n>=0&&n<=3){
cout<<"infant";
}
else if(n>=4&&n<=12){
cout<<"child";
}
else if(n>=13&&n<=18){
cout<<"youngster";
}
else{
cout<<"youth";
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
if( n<=3 )
{
cout<<"infant"<<endl;
}
else
{
if( n<=12 )
{
cout<<"child"<<endl;
}
else
{
if( n<=18 )
{
cout<<"youngster"<<endl;
}
else
{
cout<<"youth"<<endl;
}
}
}
return 0;
}
python3代码:
n=int(input())
if 0 <= n and n <= 3:
print("infant")
else:
if 4 <= n and n <= 12:
print("child")
else:
if 13 <= n and n <= 18:
print("youngster")
else:
print("youth")
a=int(input())
if 0<=a and a<=3:
print("infant")
else:
if 4<=a and a<=12:
print("child")
else:
if 13<=a and a<=18:
print("youngster")
else:
print("youth")
蓝桥杯青少创意编程python组
Python相关的考试和认证
python刷题 NOI题库 python题解 洛谷、牛客网、AcWing 刷题等
python刷题 NOI题库 python题解 洛谷、牛客网、AcWing 刷题等_acwing和洛谷哪个好-CSDN博客
Python信息技术学考一本通题目讲解、python入门、python习题集整理汇总等
Python信息技术学考一本通题目讲解、python入门、python习题集整理汇总等_信息学奥赛一本通python网站-CSDN博客
python画图系列整理