用VF做程序设计,输入字符串,统计各字符出现的次数,并提示。
1个回答
展开全部
clear
accept "请输入一串字符:" to x
store 0 to dyw,xyw,kg,sz,qt
m=len(x)
for i=1 to m
x1=substr(x,i,1)
k=asc(x1)
do case
case k=32
kg=kg+1
case k>=48 and k<=57
sz=sz+1
case k>=65 and k<=90
dyw=dyw+1
case k>=97 and k<=122
xyw=xyw+1
other
qt=qt+1
endcase
endfor
?"其中空格有: "+alltrim(str(kg))+"个"
?"大写字母有: "+alltrim(str(dyw))+"个"
?"小写字母有: "+alltrim(str(xyw))+"个"
?"数字有: "+alltrim(str(sz))+"个"
?"其它字符有: "+alltrim(str(qt))+"个"
accept "请输入一串字符:" to x
store 0 to dyw,xyw,kg,sz,qt
m=len(x)
for i=1 to m
x1=substr(x,i,1)
k=asc(x1)
do case
case k=32
kg=kg+1
case k>=48 and k<=57
sz=sz+1
case k>=65 and k<=90
dyw=dyw+1
case k>=97 and k<=122
xyw=xyw+1
other
qt=qt+1
endcase
endfor
?"其中空格有: "+alltrim(str(kg))+"个"
?"大写字母有: "+alltrim(str(dyw))+"个"
?"小写字母有: "+alltrim(str(xyw))+"个"
?"数字有: "+alltrim(str(sz))+"个"
?"其它字符有: "+alltrim(str(qt))+"个"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询