真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

斐波那契vb.net 斐波那契數(shù)列前100項

vb.net 斐波那契數(shù)列 求大神幫助?。?!

代碼:

創(chuàng)新互聯(lián)公司提供成都網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)頁設(shè)計,成都品牌網(wǎng)站建設(shè)1元廣告等致力于企業(yè)網(wǎng)站建設(shè)與公司網(wǎng)站制作,10余年的網(wǎng)站開發(fā)和建站經(jīng)驗,助力企業(yè)信息化建設(shè),成功案例突破上1000+,是您實現(xiàn)網(wǎng)站建設(shè)的好選擇.

Imports System.IO

Public Class feibo

Function fancibo(ByVal n As Integer) As Long

If n = 2 Then

Return 1

Else

Return fancibo(n - 1) + fancibo(n - 2)

End If

End Function

Sub CreateData(ByVal max As Integer)

Dim fs As New FileStream("fb.txt", FileMode.Create, FileAccess.Write)

Dim mywriter As New BinaryWriter(fs)

Dim i As Integer

For i = 1 To max

mywriter.Write(fancibo(i))

Next i

mywriter.Close()

End Sub

Sub ReadandDealData()

Dim fs As New FileStream("fb.txt", FileMode.Open, FileAccess.Read)

Dim myreader As New BinaryReader(fs)

Dim i, s As Integer

Dim tot As Long

Dim avg As Single

i = 0 : s = 0 : tot = 0 : avg = 0.0

ListBox1.Items.Clear()

While fs.Position fs.Length

s = myreader.ReadInt64()

ListBox1.Items.Add(s)

tot += s

i += 1

End While

avg = tot / i

ListBox1.Items.Add("數(shù)據(jù)的總和:" tot)

ListBox1.Items.Add("數(shù)據(jù)的平均值:" avg)

myreader.Close()

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

CreateData(15)

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

ReadandDealData()

End Sub

End Class

用vb輸出斐波那契數(shù)列前20項的所有偶數(shù)

Public Class Form1

Dim arraa%(19)

Dim i%, j%

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

? arraa(0) = 1

? arraa(1) = 1

? arraa(2) = 1

? Label2.Text = "1 ?1 ?1"

? For i = 3 To 19

? ? ? arraa(i) = arraa(i - 1) + arraa(i - 2) + arraa(i - 3)

? ? ? Label2.Text = Label2.Text " " arraa(i)

? Next

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

? For i = 3 To 19

? ? ? ? ? If ?arraa(i) Mod 2 = 0 Then?Label4.Text = Label4.Text " ? ? ? ? ?" arraa(i)

? Next

End Sub

End Class

把圖片上面的 數(shù)字改動 質(zhì)數(shù)改成偶數(shù)就可以了

貌似有一點 沒有偶數(shù) 呢

請問Vb.net編程代碼,不要C語言的,我看不懂啊?

Imports System

Module Program

Sub Main()

Dim n As Integer

n=6

Console.WriteLine("{0}!={1}",n,fact(n))

n=10

For i As Integer=1 To n

Console.Write("{0}{1}",fibo(i),IIF(n=i,vbCrLf,","))

Next

Console.Write("按任意鍵繼續(xù)。。。 ")

Console.ReadKey(True)

End Sub

' 遞歸算階乘

Function fact(n As Long) As Long

If 0=n OrElse 1=n Then Return 1

Return n*fact(n-1)

End Function

' 遞歸算斐波那契數(shù)列

Function fibo(n As Long) As Long

If 1=n OrElse 2=n Then Return 1

Return fibo(n-1)+fibo(n-2)

End Function

End Module

斐波那契數(shù)列如何用VB求和

斐波那契數(shù)列的發(fā)明者,是意大利數(shù)學(xué)家列昂納多·斐波那契.

斐波那契數(shù)列指的是這樣一個數(shù)列:1、1、2、3、5、8、13、21、……

下面是前1000項斐波那契數(shù)列的和的VB代碼:

Private Sub Command1_Click()

Dim a As Integer

Dim b As Integer

Dim c As Integer

Dim S As Long

Dim i As Integer

a = 1

b = 1

S = 2

For i = 3 To 1000

c = a + b

S = S + c

a = b

b = c

Next i

Print S

End Sub

vb怎么編寫斐波那契數(shù)列?

Sub?s()

n?=?Val(InputBox("input?n:"))

ReDim?arr(1?To?n)

arr(1)?=?1

arr(2)?=?1

Debug.Print?1;?1;

For?i?=?3?To?n

arr(i)?=?arr(i?-?1)?+?arr(i?-?2)

Debug.Print?arr(i);

Next

End?Sub

使用VB如何編寫程序求第n項斐波那契數(shù)列的值

Function F(n As Long) As Long

If n 2 Then

F = F(n - 1) + F(n - 2)

Else

F = 1

End If

End Function

Private Sub Command1_Click()

Cls

Dim I As Long

I = Val(inputbox("n=?"))

Print "第 " I " 項斐波那契數(shù)列值為:" F(i)

End Sub


文章名稱:斐波那契vb.net 斐波那契數(shù)列前100項
當(dāng)前地址:http://weahome.cn/article/hjhsod.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部