教材习题及答案 联系客服

发布时间 : 星期四 文章教材习题及答案更新完毕开始阅读f3615d5e76c66137ee0619e6

‘—7—

Module Module1

Sub Main()

Dim A() As Integer = {23, 34, 56, 78, 12, 2, 45, 6, 7, 90} Dim x As Integer = 56

Console.WriteLine(\

End Sub

Function IsHere(ByVal A() As Integer, ByVal x As Integer) As Integer For i As Integer = 0 To A.Length - 1 If x = A(i) Then Return i End If Next Return -1 End Function

End Module

‘—8—

Module Module1

Sub Main()

Console.WriteLine(\请输入工作时间,工作年数(整数),以空格分隔并以回车结束\

Dim s0 As String = Console.ReadLine() Dim sSplit() As String = s0.Split(\

Dim t, y, sperh As Integer t = Convert.ToInt32(sSplit(0)) y = Convert.ToInt32(sSplit(1)) Dim s As Single

If y >= 5 Then sperh = 50 Else

sperh = 30 End If

If t < 40 Then s = t * sperh

Else

s = 40 * sperh + (t - 40) * sperh * 1.5 End If

Console.WriteLine(\工资是{0:N2}\

End Sub

End Module

‘—9—

Module Module1

Sub Main()

Console.WriteLine(\请输入年 月 日,以空格分隔并以回车结束\ Dim s0 As String = Console.ReadLine() Dim sSplit() As String = s0.Split(\

Dim y, m, d As Integer

y = Convert.ToInt32(sSplit(0)) m = Convert.ToInt32(sSplit(1)) d = Convert.ToInt32(sSplit(2))

Dim s As Integer = 0 Dim mm As Integer

For i As Integer = 1 To m - 1

If ((i <= 7) And (i Mod 2 = 1)) Or ((i >= 8) And (i Mod 2 = 0)) Then mm = 31 Else

If i = 2 And (((y Mod 4 = 0) And (y Mod 100 <> 0)) Or (y Mod 400 = 0)) Then

mm = 29 Else

If i = 2 Then mm = 28 Else

mm = 30 End If End If End If s = s + mm Next s = s + d

Console.WriteLine(\

End Sub

End Module

‘—10—

Module Module1

Sub Main()

Console.WriteLine(\请输入n\

Dim s As String = Console.ReadLine() Dim n As Integer = Convert.ToInt32(s) Dim y As Integer = 1 For i = 1 To n - 1 y = 2 * (y + 1) Next

Console.WriteLine(\桃子数是{0}\ End Sub

End Module

‘—11—

Module Module1

Sub Main()

For x As Integer = 0 To 50

For y As Integer = 0 To 50 - x If x * 2 + y * 4 = 160 Then

Console.WriteLine(\钥匙扣{0}个,漫画书{1}本\ End If Next Next End Sub

End Module

‘—12—

Module Module1

Sub Main()

For x As Integer = 100 To 999 Dim a As Integer = x Mod 10

Dim b As Integer = (x \\ 10) Mod 10 Dim c As Integer = x \\ 100

If a ^ 3 + b ^ 3 + c ^ 3 = x Then

Console.WriteLine(\ End If Next End Sub

End Module

‘—13—

Module Module1

Sub Main()

Dim ins As String = Console.ReadLine() Dim n As Integer = Convert.ToInt32(ins) If IsSquare(n) Then

Console.WriteLine(\ Else

Console.WriteLine(\ End If End Sub

Function IsSquare(ByVal n As Integer) As Boolean Dim i As Integer = 1 For i = 1 To n / i If i * i = n Then Return True End If Next

Return False End Function

End Module

‘—14—

Module Module1 Structure count

Dim x As Integer Dim c As Integer End Structure

Sub Main()

Dim A() As Integer = {2, 3, 3, 3, 4, 5, 5, 5} Dim cou(20) As count Dim i As Integer = 0

For Each k As Integer In A