程序基本功三大基本结构-3

继续加强一下循环知识的考核
姓名
    ____________
int n = 5;

do {

    if(n == 2)

        break;

    cout << n;

    n--;

}

while(n > 0);

A.543210
B.543
C.5432
D.54321
int n = 5;

do {

    cout << n;

    if(n == 2)

        break;    

     n--;

}

while(n > 0);

A.543210
B.543
C.5432
D.54321
int n = 0;

while(n <= 5) {

    cout << n;

    if(n == 1)

        break;

    n++;

}

以上程序的输出结果为:

A.012345
B.01234
C.01
D.0
int n = 0;

while(n <= 5) {

    if(n == 1)

        break;    

    cout << n;

    n++;

}

以上程序的输出结果为:

A.012345
B.01234
C.01
D.0
int n = 0;

while(n <= 5) {

    if(n == 1)

        continue;    

    cout << n;

    n++;

}

以上程序的输出结果为:

A.01245
B.02345
C.012453
D.0
int n = 0;

while(n <= 5) {  

    cout << n;

    n++;

    if(n == 1)

        continue;  

 }

以上程序的输出结果为:

A.01245
B.02345
C.012453
D.012345

7题 | 被引用0次

使用此模板创建