磁悬浮轴承厂家:输入一字符串 输出其中大写,小写,数字的个数

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/01 16:51:10
用turbo c来实现,最好是初学者看得懂的!谢谢!

main()
{
int i,up_count=0,lo_count=0,num_count=0;
char *string;
char *p=string;
scanf("%s",string);
for(i=0;i<strlen(string);i++)
{
if( *(p+i)>65 && *(p+i)<90)
up_count++;
if(*(p+i)>97&&*(p+i)<122)
lo_count++;
if(*(p+i)>48&&*(p+i)<57)
num_count++;
}
printf("\n大写字母:%d 小写字母:%d 数字:%d",up_count,lo_count,num_count);

getch();
}

我用VFP编写:
accept to zf
store 0 to x,y,z
for i=1 to len(zf)
z=subs(zf,i,1)
if "a"<=z and z<="z"
x=x+1
endif
if "A"<=z and z<="Z"
y=y+1
endif
if "0"<=z and z<="9"
z=z+1
endif
next
?x,y,z