🥇C/C++语言100题练习专栏计划:目的:巩固练习C/C++语言,增强上机、动手实践能力,交流学习!
一、问题呈现
1.问题描述
Problem Description
现在给你一个字符,判断它是什么。
2.输入输出
Input
多组输入 每行一个字符。
Output
如果是大写字母输出“大写字母” 如果是小写字母输出“小写字母” 如果是数字输出“数字”。
3.测试样例
样例1
Sample Input
a
A
1
Sample Output
小写字母
大写字母
数字
样例2
Sample Input
A
s
D
6
Sample Output
大写字母
小写字母
大写字母
数字
二、源码实现
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char ch;
while(scanf("%c",&ch)!=EOF){
if(ch>='a'&&ch<='z')
{
cout<<"小写字母"<<endl;
}
else if(ch>='A'&&ch<='Z'){
cout<<"大写字母"<<endl;
}
else if(ch>='0'&&ch<='9')
{
cout<<"数字"<<endl;
}
}
return 0;
}
三、测试结果
A
大写字母
s
小写字母
D
大写字母
6
数字
^Z
--------------------------------
Process exited after 34.98 seconds with return value 0
请按任意键继续. . .