【正确答案】2、 编写程序,运行时按收用户键盘输入的一个长字符串,统计其中包含字母a的个数(不区分大小写),并在屏幕上输出统计结果。
set talk off
clear
accept"请输入字符串:" to s
accept"请输入字符串:" to a
x=0
if a>="A".and.a<="Z"
a=lower(a)
endif
for i=1 to len(s)
b=substr(s,i,1)
if b>="A".and.b<="Z"
b=lower(b)
endif
if b="a"
x=x+1
endif
next
?" x=",x
cancel
set talk on
【答案解析】