回 帖 发 新 帖 刷新版面

主题:请教各位高手如何求1+2+3……+100=?

如题

回复列表 (共34个回复)

21 楼

我也不会,但看了。
好像也会了。

22 楼

cls
for i=1 to 100
  read t
  s=s+t
next i
?s
data ………………

23 楼

N=100
print N*(N+1)/2

24 楼

递归法:
cls
for i=1 to 100
 s=s+i
next
你真是菜鸟,这个这么简单的问题也不会,给我……30分以上!!
 

25 楼

时间过得真快!!一转眼这个帖子已经两岁了,岁月不饶人啊……

26 楼

1.
cls
input n
print (n+1)*n/2
2.
cls
input n
for i =1 to n 
 s=s+n
next i
print s
3.
cls
input n
do while i<=n
 i=i+1
 s=s+i
loop
print s
4.
cls
input n
do until i>n
 i=i+1
 s=s+i
loop
5.
cls
input n
gosub 10
print s
end
10
i=i+1
if i>n then return else s=s+i:gosub 10
return 
6.
CLS
INPUT n
1 i = i + 1
IF i > n THEN PRINT s: END ELSE s = s + i: GOTO 1


27 楼

24楼是递归吗?不知道不要瞎说!

28 楼

cls
for i=1 to 100
s=s+i
next i
print s
end

29 楼

程序法
cls
s=0
for i=1 to 100
  s=s+i
next i
?s
end
数学法
s=(1+100)*100/2


30 楼

cls
for i=100 to 1 step -1
s=s+i
next i
?s
end

我来回复

您尚未登录,请登录后再回复。点此登录或注册