回 帖 发 新 帖 刷新版面

主题:怎样编写杨辉三角?

[em2]

回复列表 (共10个回复)

沙发

1
1  1
1  2  1
1  3  3  1
1  4  6  4  1
1  5  10 10 5 1
1  6  15 20 15 6 1
... ... ... ... ...

板凳

?"1"
?"1  1"
?"1  2  1"
?"1  3  3  1"
?"1  4  6  4  1"
?"1  5  10 10 5 1 "
?"1  6  15 20 15 6 1"
?"... ... ... ... ... "

3 楼

"我也会这么一天"这一句是什么意思?

4 楼

请各编程,而不是写出他的数据
努力呀!

5 楼

declare function f(i,j)
input n
for i=1 to n
for j=1 to i
print f(i,j);
next j
print
next i
end
function f(i,j)
if j=1 or i=j then
f=1
else
f=f(i-1,j-1)+f(i-1,j)
end if
end function
  

这样可以吗

6 楼

1
                            1   1
                          1   2   1
                        1   3   3   1
                      1   4   6   4   1
                    .   .   .   .   .   .

7 楼

INPUT N
PRINT "N=";N
DIM A(N)
FOR I = 1 TO N
A(I)=1
FOR J = I TO 1 STEP -1
IF J = 1 GOTO 95
A(J)=A(J)+a(J-1)
95 PRINT TAB(40-3*I);A(J);
NEXT J
PRINT
NEXT I
END

8 楼

input "n=";n
for i=1 to n
           for j=1 to i
                 if j=1 or j=i then
                      a(i,j)=1
                 else
                      a(i,j)=a(i-1,j-1)+a(i-1,j)
                 endif
            next j
next i
for i=1 to n

9 楼

input "n=";n
dim a(1 to n,1 to n) as integer
for i=1 to n
           for j=1 to i
                 if j=1 or j=i then
                      a(i,j)=1
                 else
                      a(i,j)=a(i-1,j-1)+a(i-1,j)
                 endif
            next j
next i
for i=1 to n
    for j=1 to i
         print a(i,j);
    next j
print
next i
end


10 楼

我有办法
print "1"
print "1  1"
print "2   3"
....

我来回复

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