VB系統(tǒng)的坐標(biāo)原點(diǎn)在左上角,X軸的正方向是水平向右,而Y軸的正方向是垂直向下。所以,要繪制三角函數(shù)的曲線,自己可以通過改變點(diǎn)坐標(biāo)的方法來實(shí)現(xiàn),當(dāng)然,VB.NET提供了相應(yīng)的方法可以來實(shí)現(xiàn)坐標(biāo)變換,也可以通過VB.Net的Graphics類提供的平移、旋轉(zhuǎn)等轉(zhuǎn)換來實(shí)現(xiàn)。
成都創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)公司一直秉承“誠信做人,踏實(shí)做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務(wù)為基礎(chǔ),以質(zhì)量求生存,以技術(shù)求發(fā)展,成交一個(gè)客戶多一個(gè)朋友!專注中小微企業(yè)官網(wǎng)定制,成都做網(wǎng)站、成都網(wǎng)站制作,塑造企業(yè)網(wǎng)絡(luò)形象打造互聯(lián)網(wǎng)企業(yè)效應(yīng)。
下面是我通過自己變換實(shí)現(xiàn)的示例,提供參考;我的環(huán)境是VB.NET 2010
Imports System.Math
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
? '1,獲得一個(gè)Graphics對象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個(gè)Pen對象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個(gè)Brush對象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? MyGraphics.DrawLine(MyPen, 0, 200, 700, 200)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
? '1,獲得一個(gè)Graphics對象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個(gè)Pen對象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個(gè)Brush對象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? '聲明橫向和縱向比例變量
? Dim Heng As Integer = 20
? Dim Zong As Integer = 50
? '先獲得正弦值,保存到點(diǎn)坐標(biāo)數(shù)組
? Dim MyPoints(700) As Point
? Dim i As Integer
? For i = 0 To 700
? ? ? MyPoints(i) = New Point(i * Heng, 200 + Sin(i) * Zong)
? Next
? '采用繪制光滑線連接點(diǎn)的方式繪制曲線
? MyGraphics.DrawCurve(MyPen, MyPoints)
End Sub
End Class
顯示的效果圖:
三角形構(gòu)成的數(shù)列
意思就是兩邊之和大于第三邊,兩邊只差小于第三邊,答案不唯一,
如“3、4、5”
遞推公式為an=a(n-1)+1
如下推導(dǎo)
a1=3
a2=4=3+1
a3=5=4+1
.
所以遞推公式為an=a(n-1)+1
參考:
以下為十行的楊輝三角輸出,根據(jù)這個(gè)自己做相應(yīng)修改,都做好了,那你就是伸手黨了。
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
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
有啊
第n行的第一個(gè)數(shù)字為1+2+3+4+……+n-1+1=n*(n-1)/2 +1
第n行最后一個(gè)數(shù)為1+2+3+……+n=n*(n+1)/2
(怎么來的呢,這是因?yàn)榈趎行第一個(gè)數(shù)是數(shù)列1,2,3,4……中第n*(n-1)/2 +1 數(shù), 因?yàn)榈谝恍?個(gè)數(shù),第二行2個(gè)數(shù),第三行3個(gè)數(shù)
一直到第n-1行有n-1個(gè)數(shù),那么第n行第一個(gè)數(shù)就是前面n-1行的個(gè)數(shù)相加再加1,同理得到第n行的最后一個(gè)數(shù),第n行有n個(gè)數(shù))
1+4+9+15???????????確定是15,不是25