主题:2道题急求
QUICKBASIC
[专家分:50] 发布于 2009-08-17 12:28:00
1.输入身份证号前17位,打印全部.
2.输入3个数,求最大公约数
回复列表 (共2个回复)
沙发
1054122 [专家分:750] 发布于 2009-08-17 12:30:00
1.CLS
INPUT "ID Card After 17 number ", a$
DIM a(17)
DIM b(17)
DIM d$(10)
FOR i = 0 TO 10
READ d$(i)
NEXT i
DATA "1","0","x","9","8","7","6","5","4","3","2"
FOR i = 1 TO 17
READ b(i)
NEXT i
DATA 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2
s = 0
FOR i = 1 TO LEN(a$)
c$ = MID$(a$, i, 1)
a(i) = VAL(c$)
s = s + a(i) * b(i)
NEXT i
yu = s MOD 11
PRINT "Finish "; a$; d$(yu)
SLEEP
END
板凳
1054122 [专家分:750] 发布于 2009-08-17 12:30:00
2.
CLS
DIM a(3)
INPUT "a , b , c = ", a(1), a(2), a(3)
FOR i = 1 TO 3 - 1
FOR j = 1 TO 3 - i
IF a(j) > a(j + 1) THEN SWAP a(j), a(j + 1)
NEXT j
NEXT i
FOR i = 1 TO a(1)
IF a(1) MOD i = 0 AND a(2) MOD i = 0 AND a(3) MOD i = 0 THEN
z = i
END IF
NEXT i
PRINT "Finish ="; z
SLEEP
END
我来回复