谁会Visual FoxPro 帮帮我

来源:百度知道 编辑:UC知道 时间:2024/07/02 16:29:18
输入一个字符串,要求分别统计出其中英文字母、空格、数字和其他字符的个数。 用Visual FoxPro 的程序做。

简单,设定输入10个字符,程序如下:
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个,否则尾部的空格会被计算在内,如果想随意输入,就必须规定字符串不能以空格结尾,程序要稍做改动.