主题:一个英语单词缺字填空的程序
梧桐秋雨1229
[专家分:0] 发布于 2006-04-21 20:55:00
请哪位高人帮一下,在此谢过了
具体要求如下:给定的10个单词,依次将每个单词中的任意两个字母替换成"_",然后显示在屏幕上,让测试者从键盘输入所缺的字母,若填写正确就加10分,错误则不加分但给出正确答案.最后,给出总得分.程序开头为:
dim a$(10)
for i=1 to 10
read a$(i)
next i
data "student","program",......
回复列表 (共5个回复)
沙发
moz [专家分:37620] 发布于 2006-04-22 13:06:00
cls
randomize timer
for i=1 to 10
color 7,0
k=0
read a$
a$=ltrim$(rtrim$(lcase$(a$)))
l=len(a$)
if l>=2 then
t1=rnd*(l-1)+1
t2=rnd*(l-1)+1
print a$;
locate ,t1
print "_";
locate ,t2
print "_";
locate ,t1,1,0,7
color 15,0
if lcase$(input$(1))=mid$(a$,t1,1) then
print mid$(a$,t1,1);
locate ,t2,1
if lcase$(input$(1))=mid$(a$,t2,1)then
print mid$(a$,t2,1);
k=-1
f=f+10
locate ,15
print ,f
endif
endif
if k=0 then
locate ,15
print ,a$
endif
endif
next
data "student","program",.....
板凳
梧桐秋雨1229 [专家分:0] 发布于 2006-04-23 16:49:00
谢谢了,不过有些语句我看不懂含义.我再认真看看
3 楼
meizi177 [专家分:70] 发布于 2006-04-23 19:16:00
dim a$(10)
for i=1 to 10
read a$(i)
next i
data "student","program",......
for i=1 to 10
len=len(a(i))
m=int (n*rnd)+ 1 :k=int (n*rnd)+ 1
if k<>m then
a$=mid$(a(i),m,1) :c$= mid$(a(i),k,1)
mid$(a(i),m,1)="-" :mid$(a(i),k,1)="-" 用"-"代替原字母
print a(i)
input "答案是" b$ ,d$ '输入答案
if a$=b$ and c$=d$ then
print "RIGHT"
s=s+10
else
print "WRONG",a$ ,c$
end if
next i
print s
end
是不是好懂了点,不过每次去的字母都是一样的!!!
4 楼
jifengg [专家分:0] 发布于 2006-05-02 01:03:00
很好啊!
5 楼
JRX [专家分:180] 发布于 2006-06-09 22:27:00
给定的10个单词,依次将每个单词中的任意两个字母替换成"_",然后显示在屏幕上,让测试者从键盘输入所缺的字母,若填写正确就加10分,错误则不加分但给出正确答案.最后,给出总得分.程序开头为:
Dim a$(10)
RANDOMIZE TIMER
for i=1 to 10
read a$(i)
next i
data "student","program",......
S=0
FOR I=1 TO 10
10: K=INT(RND*LEN(A$(I)))+1
K1=INT(RND*LEN(A$(I)))+1
IF K1=K THEN GOTO 10
IF K>K1 THEN SWAP K,K1
? LEFT$(A$(I),K-1)+"_"+MID$(A$(I),K+1,K1-K);"_";MID$(A$(I),K1+1)
INPUT A$,B$
IF A$=MID$(A$(I),K,1) AND B$=MID$(A$(I),K1,1) THEN
S=S+10
? "RIGHT!"
ELSE
? "WRONG!"
"IT'S ";MID$(A$(I),K,1);" ";MID$(A$(I),K1,1)
ENDIF
NEXT I
? "S=";S
END
我来回复