#include <stdio.h>
int
main(int argc, char *argv[])
{
char str[101]={0}
char *p=str
int digitCount=0
int letterCount=0
printf("please input a string: ")
gets(str)
printf("your input string is: %s\n",str)
while(*p!='\0')
{
if(*p>'0'&&*p<'9')
{
digitCount++
}
else if((*p>'a'&&*p<'z')||(*p>'A'&&*p<'Z'))
{
letterCount++
}
p++
}
if(digitCount==0&&letterCount==0)
{
printf("you have nothing input.\n")
}
else if(digitCount>0&&letterCount>0)
{
printf("mixed\n")
}
else if(digitCount>0&&letterCount==0)
{
printf("digit\n")
}
else if(digitCount==0&&letterCount>=0)
{
printf("letter\n")
}
else
{
//no way
}
getchar()
return 0
}
#include<stdio.h>#include<ctype.h>
#include<string.h>
main()
{
char a[10]int i,flag=1,dian=0,l
gets(a)
l=strlen(a)
if(a[0]!='-'&&!isdigit(a[0]))flag=0
for(i=1i<li++)
{
if(!isdigit(a[i])&&a[i]!='.')flag=0
if(a[i]=='.')dian++
}
if(dian>1)flag=0
if(flag==1){printf("yes!")getch()}
else exit(1)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)