运行如下程序后,命令窗口显示的结果为k=0; for n=100:200if rem(n,21)~=0 %rem为求余函数k=k+1;continueendbreak;endk
A: 105
B: 4
C: 5
D: 101
A: 105
B: 4
C: 5
D: 101
举一反三
- 中国大学MOOC: 有如下程序段: Dim i%, j%, n%, m%, k% m = 0 : k = 0 For i = 1 To 5 k = k + 1 n = 0 For j = 1 To 2 n = n + 1 m = m + 1 Next j Next i MsgBox(k & & n & & m)运行该程序代码段后,消息对话框中显示的内容为( )。
- 有如下程序段: Dim i%, j%, n%, m%, k% m = 0 : k = 0 For i = 1 To 5 k = k + 1 n = 0 For j = 1 To 2 n = n + 1 m = m + 1 Next j Next i MsgBox(k & " " & n & " " & m)运行该程序代码段后,消息对话框中显示的内容为( )。 A: 5 10 2 B: 5 10 10 C: 5 2 10 D: 5 2 2
- 下面程序是求100~200的全部素数,请填空 main() { int n, i, k, m = 0; for (n = 101; n <= 200; n = n + 2) { k = sqrt(n); for (i = 2; i <= k; i++) if (n%i == 0) ; if ( ) { printf("%d ", n); m = m + 1; } if (m % 10 == 0) printf("\n"); } printf("\n"); }
- 下述程序段中, 与其他程序段的作用不同。 A: k=1; while (1) { s+=k ; k=k+1 ; if (k>100) break ; } printf(“\n%d”,s) ; B: k=1; Repeat : s+=k ; if (++k<=100) goto Repeat printf(“\n%d”,s) ; C: int k,s=0; for (k=1;k<=100;s+=++k); printf(“\n%d”,s) ; D: k=1; do s+=k; while (++k<=100) ;printf(“\n%d”,s) ;
- 有如下的程序段: Dim a(4) As Integer Dim b(4) As Integer For k=0 To 2 a(k+1)=Val(InputBox("Enter data:")) b(3-k)=a(k+1) Next k Print b(k) 程序运行后,依次输入1,3,5,输出的结果是______________。 A: 1 B: 3 C: 5 D: 0