中国大学MOOC: Dim i,j,x For i=i To 20 step 2 x=0 For j=i To 20 step 3 x=x+1 Next j Next i Textl.Value=Str(x)End Sub文本框中显示的结果
举一反三
- Dim i,j,x For i=i To 20 step 2 x=0 For j=i To 20 step 3 x=x+1 Next j Next i Textl.Value=Str(x)End Sub文本框中显示的结果 A: 1 B: 2 C: 0 D: 3
- 运行下面的程序,第二行显示结果是___________。 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
- 下列程序段的执行结果为; Dim X(3,5) For I=1 To 3 For J=1 To 5 X(I,J)=X(I-1,J-1)+I+J Next J Next I Print X(3,4) A: 12 B: 10 C: 18 D: 15
- 在窗体上添加一个命令按钮Command1,然后编写如下事件过程: Private Sub Command1_Click() For i = 1 To 4 x = 4 For j = 1 To 3 x = 3 For k = 1 To 2 x = x + 6 Next k Next j Next i Print x End Sub 程序运行后,单击命令按钮,显示结果为( )。
- 中国大学MOOC: 写出下面程序执行后的运行结果。#include <stdio.h>int main(){int x[]={1,3,5,7,2,4,6,0},i,j,k;for(i=0;i<3;i++)for (j=2;j>=i;j--)if(x[j+1]>x[j]) { k=x[j]; x[j]=x[j+1]; x[j+1]=k;}for(i=0;i<3;i++)for(j=4;j<7-i;j++)if(x[j+1]>x[j]) { k=x[j]; x[j]=x[j+1]; x[j+1]=k;}for (i=0;i<3;i++)for(j=4;j<7-i;j++)if(x[j]>x[j+1]) { k=x[j]; x[j]=x[j+1]; x[j+1]=k;}for (i=0;i<8;i++) printf("%d",x[i]); return 0;}