3123:【例21.3】 字符类型判断(C、C++、python)

3123:【例21.3】 字符类型判断

信息学奥赛一本通-编程启蒙(C++版)在线评测系统

[例 21.3] 字符类型判断

信息学奥赛一本通-编程启蒙(C++版)在线评测系统




C语言源码:

#include <stdio.h> 
#include <stdlib.h>
int main()
{
	char a;
	
	scanf("%c",&a);

	if('A'<=a&&a<='Z') printf("upper");
	else if('a'<=a&&a<='z') printf("lower");
	else if('0'<=a&&a<='9') printf("digit");
	else printf("other");
	
	return 0;
}


C++代码:

#include <bits/stdc++.h>
using namespace std;
long long n;
char c;
int main(){
    cin >> c;
    if(c >= 'A' and c <= 'Z')//是否大写字符
        cout << "upper";
    else if(c >= '0' and c <= '9')//是否数字
        cout << "digit";
    else if(c >= 'a' and c <= 'z')//是否小写字符
        cout << "lower";
    else//是否其它字符
        cout << "other";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	char ch;
	cin>>ch;
	
	if( ch>='a' && ch<='z' )
	{
		cout<<"lower"<<endl;
	}
	else
	{
		if( ch>='A' && ch<='Z' )
		{
			cout<<"upper"<<endl;
		}
		else
		{
			if( ch>='0' && ch<='9' )
			{
				cout<<"digit"<<endl;
			}
			else
			{
				cout<<"other"<<endl;
			}
		}
	}
    
    return 0;
}


python3代码:

a=input()

if 'A'<=a and a<='Z':
    print("upper")
elif 'a'<=a and a<='z':
    print("lower")
elif '0'<=a and a<='9':
    print("digit")
else :
    print("other")



 




3065:练12.4计算并联电阻的阻值(Scratch、C、C++、python)

3065:练12.4计算并联电阻的阻值(Scratch、C、C++、python)-CSDN博客

3066:【例13.1】空格分隔输出(C、C++)

3066:【例13.1】空格分隔输出(C、C++)_3066:【例13.1】空格分隔输出-CSDN博客

3067:【例13.2】 电子表(Scratch、C、C++、python)

3067:【例13.2】 电子表(Scratch、C、C++、python)_c++ 编程 电子表-CSDN博客

3068:【例13.3】时间差(C、C++、python)

3068:【例13.3】时间差(C、C++、python)-CSDN博客

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

dllglvzhenfeng

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

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

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

打赏作者

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

抵扣说明:

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

余额充值