问题
单项选择题
在窗体上有一个命令按钮Command1,编写下列程序:
Private Sub Command1_Click()
Print ppl(3,7)
End Sub
Public Function ppl(X As Single,n As Integer)As Single
If n=0Then
ppl=1
Else
If n M0d 2=1 Then
ppl=x*x+n
EIse
ppl=x*x-n
End If
End If
End Function
程序运行后,单击该命令按钮,屏幕上显示的是( )
A.2
B.1
C.0
D.16
答案
参考答案:D
解析: 本题比较简单,只要根据程序的执行条件和顺序,就可以运算出该程序的最后输出结果。程序运算过程是:If n=0 Then...else if nMod 2=1 Then ppl=x*x+n,所以结果为16。