Public Class Form1
成都创新互联服务项目包括原平网站建设、原平网站制作、原平网页制作以及原平网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,原平网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到原平省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j As Integer
Dim n As Integer
n = 10
Dim dete(n, n) As Integer
Dim sum As Integer
For i = 0 To n
For j = 0 To i
If i = 0 Then
dete(i, j) = 1
ElseIf j = 0 Then
dete(i, j) = 1
ElseIf i = j Then
dete(i, j) = 1
Else
dete(i, j) = dete(i - 1, j - 1) + dete(i - 1, j)
End If
Next
Next
For i = 0 To n
For j = 0 To i
Debug.Write(dete(i, j) " ")
sum += dete(i, j)
Next
Debug.WriteLine(" ")
Next
Debug.WriteLine(" 所有数的和:" sum)
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim n As Integer, i As Integer, j As Integer, a(,) As Integer
n = 10
ReDim a(n + 1, n + 1)
For i = 1 To n + 1
a(i, 1) = 1 : a(i, i) = 1 : Next i
For i = 3 To n + 1
For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j)
Next j, i
For i = 1 To n + 1
For j = 1 To i
TextBox1.AppendText(Space(4 - Len(Trim(Str(a(i, j))))) Trim(Str(a(i, j))))
Next j
TextBox1.AppendText(vbCrLf)
Next i
End Sub
End Class,9,
xixihahano1 举报
谢谢了,但是你写的代码可以输出多少行?多久会溢出了
举报 ccddty
没试过,你可以试试,将n的值加大 当n》16的时候就显示“参数“Number”必须大于或等于 0。”了 有没有办法解决?,
参考:
以下为十行的杨辉三角输出,根据这个自己做相应修改,都做好了,那你就是伸手党了。
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j As Integer
Dim n As Integer
n = 10
Dim dete(n, n) As Integer
Dim sum As Integer
For i = 0 To n
For j = 0 To i
If i = 0 Then
dete(i, j) = 1
ElseIf j = 0 Then
dete(i, j) = 1
ElseIf i = j Then
dete(i, j) = 1
Else
dete(i, j) = dete(i - 1, j - 1) + dete(i - 1, j)
End If
Next
Next
For i = 0 To n
For j = 0 To i
Debug.Write(dete(i, j) " ")
sum += dete(i, j)
Next
Debug.WriteLine(" ")
Next
End Sub
End Class
网站名称:杨辉三角vb.net 杨辉三角形c语言程序
本文URL:https://www.cdcxhl.com/article46/doidhhg.html
成都网站建设公司_创新互联,为您提供网站导航、搜索引擎优化、服务器托管、品牌网站制作、ChatGPT、定制开发
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联