33,311
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
void main( )
{
printf("请数输入一个字符:");
char ch = getchar();
if(ch>= 'a'&&ch<= 'z')
printf("该字符是小写字母");
else if(ch >= 'A'&&ch <='Z')
printf("该字符是大写字母");
else if(ch>='0'&&ch <='9')
printf("该字符是数字");
else
printf("该字符是其他字符") ;
printf("\n") ;
system("pause");
}
#include <stdio.h>
#include <string.h>
char s[80];
int i;
char c;
int main() {
while (1) {
printf("Input a integer:");fflush(stdout);
rewind(stdin);
fgets(s,80,stdin);
if (strlen(s)>10) {
printf("Input too long(>9)!\n");
continue;
}
if (2==sscanf(s,"%d%c",&i,&c)) {
if ('\n'==c) {
printf("%d is a integer.\n",i);
break;
}
}
if ('\n'==s[strlen(s)-1]) s[strlen(s)-1]=0;
printf("\"%s\" is NOT a integer!\n",s);
}
return 0;
}