#杨辉三角
input “请输入行数” to a
for i=0 to a
?
for j=0 to i
??allt(str(sum(1,i)))+space(2)
endfor
endfor
function sum
parameter x,y
store 1 to b,c
for n=1 to x
b=b*n
c=c*y
y=y-1
endfor
return c/b
觉得不错的话留个赞呗´・ᴗ・`
本文介绍了一种使用编程语言实现杨辉三角的方法,通过双重循环结构,利用组合数公式计算每一项的值,并以字符串形式输出,形成杨辉三角的形状。作者邀请读者为这篇内容点赞。
#杨辉三角
input “请输入行数” to a
for i=0 to a
?
for j=0 to i
??allt(str(sum(1,i)))+space(2)
endfor
endfor
function sum
parameter x,y
store 1 to b,c
for n=1 to x
b=b*n
c=c*y
y=y-1
endfor
return c/b
觉得不错的话留个赞呗´・ᴗ・`
304

被折叠的 条评论
为什么被折叠?