vf编程问题:如果输出一个由字母,数字和其他字母组成的一字符串,统计出字母,数字,空格和其他字符的个

来源:百度知道 编辑:UC知道 时间:2024/06/01 21:16:01

程序如下:
clea
j=0
n=0
num=0
word=0
spa=0
oth=0
sub=space(10)
@4,4 say '输入字符串:(小于10个)' get sub
read

j=len(sub)

for i=1 to j
n=subs(sub,i,1)

do case
case asc(n)>=97.and.asc(n)<=122
word=word+1
case asc(n)>=65.and.asc(n)<=90
word=word+1
case asc(n)>=48.and.asc(n)<=57
num=num+1
case asc(n)=32
spa=spa+1
othe
oth=oth+1
endcase
endfor
@6,4 say sub
@7,4 say '字符个数:'
@7,14 say word
@8,4 say '数字个数:'
@8,14 say num
@9,4 say '空格个数:'
@9,14 say spa
@10,4 say '其它字符:'
@10,14 say oth

注意:该程序输入字符串时,必须输入10个,否则尾部的空格会被计算在内,如果想随意输入,就必须规定字符串不能以空格结尾,程序要稍做改动.