我是小学生想用QBASIC
统计数字问题
答案:1 悬赏:20 手机版
解决时间 2021-05-18 14:03
- 提问者网友:凉末
- 2021-05-18 10:58
最佳答案
- 五星知识达人网友:痴妹与他
- 2021-05-18 11:41
CLS
DIM j, n, num As LONG
DIM k As Integer, a(9) AS INTEGER, i AS INTEGER
INPUT N
FOR j = 1 TO n
num = j
k = LEN(CSTR(num))
FOR i = 1 TO k
SELECT CASE num MOD 10
CASE 0: a(0) = a(0) + 1
CASE 1: a(1) = a(1) + 1
CASE 2: a(2) = a(2) + 1
CASE 3: a(3) = a(3) + 1
CASE 4: a(4) = a(4) + 1
CASE 5: a(5) = a(5) + 1
CASE 6: a(6) = a(6) + 1
CASE 7: a(7) = a(7) + 1
CASE 8: a(8) = a(8) + 1
CASE 9: a(9) = a(9) + 1
END SELECT
num = INT(num / 10)
NEXT i
NEXT j
FOR i = 0 TO 9
PRINT "数字" ,i,"的个数为: " ,a(i)
Next i
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯