主题:[原创]字符串 记忆游戏
DECLARE FUNCTION GetString$ (myMod%)
CLS
RANDOMIZE TIMER
DEFINT A-Z
DIM a AS STRING * 1
DIM theString AS STRING
DIM rememberString AS STRING
INPUT "Please input the number of charactor:"; n
INPUT "Please input the mod(1=digital,2=char,3=all):"; myMod
INPUT "Please input the time for member:"; memberTime
FOR i = 1 TO n
COLOR INT(RND * 8 + 8)
a$ = GetString$(myMod)
PRINT a$;
theString$ = theString$ + a$
NEXT i
SLEEP memberTime
CLS
INPUT "Please input the string you remember:"; rememberString$
FOR i = 1 TO n
IF MID$(theString$, i, 1) = MID$(UCASE$(rememberString$), i, 1) THEN RIGHT = RIGHT + 1
NEXT
PRINT "The right string is: "; theString$
PRINT "You have "; n - RIGHT; " mistakes."
PRINT "Your score is :"; FIX(RIGHT / n) * 10
REM ============================================
FUNCTION GetString$ (myMod)
DIM a AS STRING * 1
SELECT CASE myMod
CASE 1
a$ = CHR$(INT(RND * 10) + 48)
CASE 2
a$ = CHR$(INT(RND * 26) + 65)
CASE 3
IF INT(RND * 2) = 0 THEN
a$ = CHR$(INT(RND * 10) + 49)
ELSE
a$ = CHR$(INT(RND * 26) + 65)
END IF
END SELECT
GetString$ = a$
END FUNCTION
上传 用FREE BASIC 编译的……
CLS
RANDOMIZE TIMER
DEFINT A-Z
DIM a AS STRING * 1
DIM theString AS STRING
DIM rememberString AS STRING
INPUT "Please input the number of charactor:"; n
INPUT "Please input the mod(1=digital,2=char,3=all):"; myMod
INPUT "Please input the time for member:"; memberTime
FOR i = 1 TO n
COLOR INT(RND * 8 + 8)
a$ = GetString$(myMod)
PRINT a$;
theString$ = theString$ + a$
NEXT i
SLEEP memberTime
CLS
INPUT "Please input the string you remember:"; rememberString$
FOR i = 1 TO n
IF MID$(theString$, i, 1) = MID$(UCASE$(rememberString$), i, 1) THEN RIGHT = RIGHT + 1
NEXT
PRINT "The right string is: "; theString$
PRINT "You have "; n - RIGHT; " mistakes."
PRINT "Your score is :"; FIX(RIGHT / n) * 10
REM ============================================
FUNCTION GetString$ (myMod)
DIM a AS STRING * 1
SELECT CASE myMod
CASE 1
a$ = CHR$(INT(RND * 10) + 48)
CASE 2
a$ = CHR$(INT(RND * 26) + 65)
CASE 3
IF INT(RND * 2) = 0 THEN
a$ = CHR$(INT(RND * 10) + 49)
ELSE
a$ = CHR$(INT(RND * 26) + 65)
END IF
END SELECT
GetString$ = a$
END FUNCTION
上传 用FREE BASIC 编译的……