求一道VFP题答案 谢谢了

来源:百度知道 编辑:UC知道 时间:2024/05/15 09:22:58
输入一个字符串,要求分别统计出其中 英文字母、空格、数字和其他字符的个数

这儿有一段,希望于你有用,改一下应该可以:
store 0 to dx,xx,hz,qt,kg
accept"请输入一个字符串"to a
leng=len(a)
for i=1 to leng
if asc(subs(a,i,1))>128
m=subs(a,i-1,2)
hz=hz+1
else
m=subs(a,i,1)
endif
do case
case asc(m)>=65 and asc(m)<=90
dx=dx+1
case asc(m)>=97 and asc(m)<=122
xx=xx+1
case asc(m)=32
kg=kg+1
otherwise
qt=qt+1
endcase
endfor
?"字符串长度为:",allt(str(leng)),"个"
?"大写字母为:",allt(str(dx)),"个"
?"小写字母为:",allt(str(xx)),"个"
?"汉字为:",allt(str(hz)),"个"
?"空格为:",allt(str(kg)),"个"
?"其他字符为:",allt(str(qt)),"个"