期末復習題(1)_第1頁
期末復習題(1)_第2頁
期末復習題(1)_第3頁
期末復習題(1)_第4頁
期末復習題(1)_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

1、編寫判斷一個正整數(shù)是否為“水仙花數(shù)”的函數(shù)過程。在事件過程中調(diào)用該過程,計算區(qū)間200,500上“水仙花數(shù)”的個數(shù),并顯示所有水仙花數(shù)?!八苫〝?shù)”的含義是一個數(shù)的每個數(shù)位的立方和等于該數(shù)。例153=13+53+33。結(jié)果:3Function sxhs(ByVal n As Integer) As Boolean Dim bw, gw, sw As Integer bw = n 100 sw = (n Mod 100) 10 gw = n Mod 10 If bw 3 + sw 3 + gw 3 = n Then sxhs = True Else sxhs = False End If End

2、 Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim m, i As Integer Dim s1 As String m = 0 For i = 200 To 500 If sxhs(i) Then s1 = s1 + Str(i) m = m + 1 End If Next MsgBox(Str(m) + vbCrLf + s1)End Sub301、編寫程序,計算并輸出下列數(shù)列前35項的和。 (1-2

3、-3),(4-5-6),(7-8-9), ,(3n+1)-(3n+2)-(3n+3), (注意,n=0,1,2,3)-1925Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, s As Integer s = 0 For i = 0 To 34 s += (3 * i + 1) - (3 * i + 2) - (3 * i + 3) Next MsgBox(s) End Sub 521.已知數(shù)據(jù)文件da5.dat中已

4、存儲有20個學生一門課程的成績(整型),編程將該文件中20個學生的成績賦給整型數(shù)組score,然后按照從高分到低分對成績排序,并按一行五個輸出顯示。Dim score(19), i, j, t As Integer Dim str1 As String = FileOpen(1, d:da5.dat, OpenMode.Input) For i = 0 To 19 Input(1, score(i) Next FileClose(1) For i = 0 To 18 For j = i + 1 To 19 If score(i) = 90) Then n = n + 1 End If tota

5、l = total + cj i = i + 1 End While If i 0 Then aver = total / i End If MsgBox(total= + CStr(total) + + aver= + CStr(aver) + + i= + CStr(i) + + n= + CStr(n) Write(2, aver, n) FileClose(1) FileClose(2)End Sub1A1. 編寫程序,計算并輸出下面數(shù)列前n項的和 (設n=20,結(jié)果取4位小數(shù))。 數(shù)列為: 2/1,3/2,5/3,8/5,13/8,21/13,dim a,b, t,i,n as integerdim sum,q as si

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論