早教吧作业答案频道 -->其他-->
输入整数n,显示出具有n行的杨辉三角形要求:输出的杨辉三角是正三角形
题目详情
输入整数n,显示出具有n行的杨辉三角形
要求:输出的杨辉三角是正三角形
要求:输出的杨辉三角是正三角形
▼优质解答
答案和解析
Dim arrYangHui%(10, 10)
Dim i, j%
For i = 1 To 10
arrYangHui(i, 1) = 1
arrYangHui(i, i) = 1
Next
For i = 2 To 10
For j = 2 To i - 1
arrYangHui(i, j) = arrYangHui(i - 1, j - 1) + arrYangHui(i - 1, j)
Next
Next
Dim MyGraphics As Graphics
' 声明图形变量
MyGraphics = Me.CreateGraphics()
' 将当前窗体设置为图形对象
Dim MyFont As New Font("隶书", 14, FontStyle.Regular, GraphicsUnit.Point)
' 声明字体对象
Dim MyBrush As New SolidBrush(Color.Black)
' 声明黑色的刷子对象
Dim MyPos As New PointF(0, 0)
' 声明一个点对象
Dim strChars$, intLen%
For i = 1 To arrYangHui.GetUpperBound(0)
MyPos.X = 0
For j = 1 To i
strChars = Trim(Str(arrYangHui(i, j)))
intLen = Len(strChars)
strChars = Space(8 - intLen) & strChars
MyGraphics.DrawString(strChars, MyFont, MyBrush, MyPos)
MyPos.X += 8 * MyFont.Size * 2 / 3
' 字体的全身大小的2/3
Next
MyPos.Y += MyFont.GetHeight()
' 字体的行距
Next
Dim i, j%
For i = 1 To 10
arrYangHui(i, 1) = 1
arrYangHui(i, i) = 1
Next
For i = 2 To 10
For j = 2 To i - 1
arrYangHui(i, j) = arrYangHui(i - 1, j - 1) + arrYangHui(i - 1, j)
Next
Next
Dim MyGraphics As Graphics
' 声明图形变量
MyGraphics = Me.CreateGraphics()
' 将当前窗体设置为图形对象
Dim MyFont As New Font("隶书", 14, FontStyle.Regular, GraphicsUnit.Point)
' 声明字体对象
Dim MyBrush As New SolidBrush(Color.Black)
' 声明黑色的刷子对象
Dim MyPos As New PointF(0, 0)
' 声明一个点对象
Dim strChars$, intLen%
For i = 1 To arrYangHui.GetUpperBound(0)
MyPos.X = 0
For j = 1 To i
strChars = Trim(Str(arrYangHui(i, j)))
intLen = Len(strChars)
strChars = Space(8 - intLen) & strChars
MyGraphics.DrawString(strChars, MyFont, MyBrush, MyPos)
MyPos.X += 8 * MyFont.Size * 2 / 3
' 字体的全身大小的2/3
Next
MyPos.Y += MyFont.GetHeight()
' 字体的行距
Next
看了 输入整数n,显示出具有n行的...的网友还看了以下:
1、x²-(2+2根号3)x+5+3根号三=02、(2x²-3x-2)m²=mn(1+x²)-(1 2020-04-07 …
已知a+b=1,ab=-1设S(1)=a+bS(2)=a²+b²S(3)=a三次方+b三次方S(n 2020-06-12 …
输入整数n,显示出具有n行的杨辉三角形要求:输出的杨辉三角是正三角形 2020-08-02 …
这个卡西欧5800P单一闭附合图根水准路线近似平差计算公式哪一步有问题?当计算器出现错误时显示是第 2020-08-02 …
VB.Net的问题,输入整数n,显示具有n行的杨辉三角形.输入整数n,显示具有n行的杨辉三角形.提 2020-08-04 …
观察表中三角形个数的变化规律:图形横截线条数012…n三角形个数6??…?若三角形的横截线有0条,则 2020-11-19 …
从n个数中取k个数可以重复有多少种不同的取法如果是n^k显然重复了很多n+k-1)忘说了123312 2020-12-02 …
阅读下面的文字,完成1-3题。不染袁炳发高三生杨直清华、北大任他选读。老师和同学都这么认为。但杨直家 2020-12-04 …
11.(2014•甘肃民乐一中期中)番茄的红果(R)对黄果(r)是显性,让杂合的红果番茄自交得F1, 2020-12-22 …
杨辉三角队列的实现利用循环顺序队列打印杨辉三角.杨辉三角的特点是两个腰上的数字都为1,其它位置上的利 2020-12-24 …