求满足如下条件的三位数。它除以 11 所得的商等于各位数字的平方和。例如: 550/11=50=5 × 5+5 × 5+0 。完善下列程序。 Private Sub Form_Click() Dim a As Integer, b As Integer, c As Integer, n As Integer, j As Integer For a=___________ For b=0 To 9 For c=0 To 9 N=_____________ If (n mod 11=0) and (n\11=a*a+b*b+c*c) then Print n; "/11=";n/11; "=";a*a; b*b; c*c End if Next c _______________ Next a End Sub
举一反三
- 运行下面的程序,第二行显示结果是___________。 Private Sub Form_Click() Dim A As Integer Dim i As Integer A = 5 For i = 1 To 9 Call sub1(i, A) Print i, A Next i End Sub Private Sub sub1(x As Integer, y As Integer) Static N As Integer Dim I As Integer For I = 3 To 1 Step -1 N = N + x x = x + 2 Next I y = y + N End Sub
- 如下程序的运行结果是【1】. Private Sub Command1_Click() Dim x As Integer x = 12 f2 x Print x End Sub Public Sub f2(n As Integer) n = n Mod 10 End Sub
- 求给定自然数m和n的最大公约数。请完善程序。 Private Sub Command1_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r Do r = m Mod n m = n n = r Loop Until__________ Text3.Text = m End Sub Private Sub Command2_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r r = m Mod n Do Until _______ m = n n = r r = m Mod n Loop Text3.Text =____ End Sub Private Sub Command3_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r Do r = m Mod n m = n n = r Loop While________ Text3.Text =______ End Sub Private Sub Command4_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r r = m Mod n Do While______ m = n n = r r = m Mod n Loop Text3.Text =____ End Sube73f1fd63959cc8362d8c82d419c2353.png
- 窗体上有一个名称为Command1的命令按钮,其中部分代码如下:Private Sub Command1_Click()Dim a(10)As IntegerDim n As Integer……Call calc(a,n)……End Subcalc过程的首行应该是()。 A: Sub calc(x() As Integer, n As Integer) B: Public Sub calc(x() As Integer) C: Private Sub calc(a(n) As Integer, n As Integer) D: Public Sub calc(a As Integer, n As Integer)
- 下列程序运行时输出的结果是 Option Base 1 Private Sub Form_Click() Dim x (10)As Integer,y(5)As Integer For i=1 to 10 x(i)=10-i+1 Next For i=1 to 5 y(i)=x(2*i-1)+x(2*i) Next For i=1 to 5 Print y(i) Next End Sub A.3 7 11 45 19 B.19 15 11 7 3 C.1 3 5 7 9 D.不确定的值