主题:回者加分
游戏之王
[专家分:540] 发布于 2007-08-14 09:52:00
输入一个字符串,内有数字和非数字字符。如A123X456Y7A,302ATB567BCC,打印字符串中所有连续(指不含非数字字符)的数字所组成的整数,并统计共有多少个整数。
回复列表 (共4个回复)
沙发
网虫一号 [专家分:1230] 发布于 2007-08-14 09:55:00
CLS
INPUT x$: l = LEN(x$)
FOR i = 1 TO l
m$ = MID$(x$, i, 1)
IF m$ < "0" OR m$ > "9" THEN 10
y$ = y$ + m$
IF i < l THEN R$ = MID$(x$, i + 1, 1)
IF i < l AND (R$ < "0" OR R$ > "9") THEN PRINT y$: S = S + 1: y$ = ""
10 NEXT i
PRINT "S="; S
END
板凳
小精灵1号 [专家分:1040] 发布于 2007-08-14 10:19:00
CLS
INPUT x$: l = LEN(x$)
FOR i = 1 TO l
m$ = MID$(x$, i, 1)
IF m$ < "0" OR m$ > "9" THEN 10
y$ = y$ + m$
IF i < l THEN R$ = MID$(x$, i + 1, 1)
IF i < l AND (R$ < "0" OR R$ > "9") THEN PRINT y$: S = S + 1: y$ = ""
10 NEXT i
PRINT "S="; S
END
3 楼
小小傻瓜 [专家分:150] 发布于 2007-08-14 12:49:00
CLS
INPUT x$: l = LEN(x$)
FOR i = 1 TO l
m$ = MID$(x$, i, 1)
IF m$ < "0" OR m$ > "9" THEN 10
y$ = y$ + m$
IF i < l THEN R$ = MID$(x$, i + 1, 1)
IF i < l AND (R$ < "0" OR R$ > "9") THEN PRINT y$: S = S + 1: y$ = ""
10 NEXT i
PRINT "S="; S
END
4 楼
hxy_anhui [专家分:320] 发布于 2009-01-29 22:03:00
CLS
INPUT A$
FOR I = 1 TO LEN(A$)
IF MID$(A$, I, 1) >= "0" AND MID$(A$, I, 1) <= "9" THEN
S = I
X = 0
DO UNTIL MID$(A$, S, 1) < "0" OR MID$(A$, S, 1) > "9"
X = X * 10 + VAL(MID$(A$, S, 1))
S = S + 1
LOOP
PRINT X; : I = I + LEN(LTRIM$(STR$(X)))
W = W + 1
END IF
NEXT I
PRINT
PRINT W
END
我来回复