游客 Signup | Login
中文 | En

3462 - 判断字符

通过键盘输入一个字符,判断该字符是数字字符、大写字母、小写字母、空格还是其他字符

Input

输入一个字符。

Output

如果是字母 输出"It is an English character!"

如果是数字 输出"It is a digit character!"

如果是空格 输出"It is a space character!"

如果是其他字符 输出"It is other character!"

Examples

Input

1
a
,

Output

It is a digit character!
It is an English character!
It is other character!

Solution C

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
int main()
{
 //   freopen("in","r",stdin);
//    freopen("out","w",stdout);

	char  ch;
    while(scanf("%c", &ch)!=EOF)
    {

     getchar();

	if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
	{
		printf("It is an English character!\n");
	}
	else if (ch <= '9' && ch >= '0')
	{
	    	printf("It is a digit character!\n");
	}
	else if (ch == ' ')
	{
	    	printf("It is a space character!\n");
	}
	else
	{
		printf("It is other character!\n");
	}




    }
  return 0;
}

Solution C++

#include<cstdio>
int main()
{
	char ch;
	while (scanf("%c", &ch) != EOF)
	{
		if (ch >= '0'&&ch <= '9')
			printf("It is a digit character!\n");
		else if ((ch >= 'A'&&ch <= 'Z') || (ch >= 'a'&&ch <= 'z'))
			printf("It is an English character!\n");
		else if (ch == ' ')
			printf("It is a space character!\n");
		else
			printf("It is other character!\n");
		getchar();
	}
	
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题