回 帖 发 新 帖 刷新版面

主题:一个英语单词缺字填空的程序

请哪位高人帮一下,在此谢过了
 具体要求如下:给定的10个单词,依次将每个单词中的任意两个字母替换成"_",然后显示在屏幕上,让测试者从键盘输入所缺的字母,若填写正确就加10分,错误则不加分但给出正确答案.最后,给出总得分.程序开头为:
               dim a$(10)
               for i=1 to 10
               read a$(i)
               next i
               data "student","program",......

回复列表 (共5个回复)

沙发

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",.....

板凳

谢谢了,不过有些语句我看不懂含义.我再认真看看

3 楼

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 楼

很好啊!

5 楼

给定的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

我来回复

您尚未登录,请登录后再回复。点此登录或注册