试题 试卷
题型:单选题 题类: 难易度:困难
江苏省南通市海安市高级中学2022-2023学年高一下学期信息技术期中考试试卷
def f(n):
if n == 5:
return ___①___
else:
return _____②____
print(___③___)
Private Sub Command1_Click()
Text1.Text = f(3)
End Sub
Function f(x As Integer) As String
If x = 1 Then f = 1 Else f = f(x - 1) + 2
End Function
运行程序并点击按钮Command1后,文本框Text1中显示的内容是( )
Function f(n As Integer)As Long
Text1.Text=Trim(Str(n))+Text1.Text ‘函数Trim的作用是去掉字串首尾空格
If n=1 Then
f=1
Else
f=3*f(n\2)
End If
Text1.Text=“”
Text1.Text=Trim(Str(f(8)))+Text1.Text
单击按钮Command1后,文本框Text1中显示的值是( )
请完善下列程序代码:
Function prime(x As Integer) As Boolean ’此函数判断x是否为质数
prime = True
For i = 2 To Int(Sqr(x))
If {#blank#}1{#/blank#} Then prime = False: Exit For
Next i
Private Sub Command2_Click()
Dim a As Integer, b As Integer
Dim n As Integer
{#blank#}2{#/blank#}
For a = 2 To n \ 2
b = n - a
If {#blank#}3{#/blank#} Then
List1.AddItem Str(a) + " " + Str(b) + " " + Str(n)
Next
Do While i <= 5
If i = 1 Or a(i - 1) <= a(i) Then i = i + 1
t = a(i): a(i) = a(i - 1): a(i - 1) = t i = i - 1
End If Loop
数组元素a(0)到a(8)的初始值依次为“0,4,7,3,5,1,8,6,2”。执行该程序段后,数组元素a(1)到a(8)的值分别是
Dim a(4) As Integer
Dim s As String
a(1)=10:a(2)=30:a(3)=20:a(4)=40
s=doit(4)
Label1.Caption=s
Function doit(k As Integer) As String
If k=1 Then
doit=Str(a(1))
doit=doit(k-1) & Str(a(k))
程序运行后,标签Label1中显示的内容是( )
试题篮