一道qbasic的编程题!!!!

来源:百度知道 编辑:UC知道 时间:2024/04/28 21:51:40
求1,2,3……n这一数列的数字和
比如
11=1+2+3+4+5+6+7+8+9+1+0+1+1
数字和
给一个公式:数位=int[(log(数)/log(10)]+1

一楼是错的!注意:是11=1+2+3+4+5+6+7+8+9+1+0+1+1,而不是11=1+2+3+4+5+6+7+8+9+10+11
input n
for i=1 to n
x$=mid$(str$(i),2)
l=len(x$)
for j=1 to l
s=s+val(mid$(x$,1))
next j
next i
print s

N = 11
S = 0
FOR X = 1 TO N
S = S + N
NEXT
PRINT S