> 数学 >
统计数字出现的次数:从键盘输入5个正整数,统计出现数字0.1.2.3……9的出现次数.
FREEBASIC
人气:208 ℃ 时间:2020-03-17 15:24:13
解答
DIM AS INTEGER A(5),C(9)
FOR I=1 TO 5
INPUT A(I)
NEXT I
FOR I=1 TO 5
T=A(I)
DO WHILE T0
T=T\10
S=S+1
LOOP
T=A(I)
DIM B(S) AS INTEGER
FOR J=1 TO S
DO WHILE T0
B(J)=T MOD 10
T=T\10
LOOP
NEXT J
FOR J=1 TO S
FOR K=1 TO 9
IF B(J)=K THEN C(K)=C(K)+1
NEXT K
NEXT J
NEXT I
FOR I=1 TO 9
PRINT C(I),
NEXT I
SLEEP
END
别浪费了哦,我打字打了半天呢!
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版