1.以下選項(xiàng)中循環(huán)結(jié)構(gòu)合法的是( )
A钉汗、while (int?i<7)
{?i++;
?System.out.println(“i is “+i);
?}
B家肯、?int?j=3;
while(j)
{?
System.out.println(“ j?is “+j);
}
C官紫、int?j=0;
for(int?k=0; j + k !=10; j++,k++)
{???
System.out.println(“ j?is “+ j + “k?is”+ k);
}
D钳榨、?int?j=0;
do{
??System.out.println( “j?is “+j++);
??if (j = = 3) {continue?loop;}
?}while?(j<10);
2.有如下程序段:
int total = 0;
for ( int i = 0; i < 4; i++ ){
?if ( i == 1) continue;
?if ( i == 2)?break;??????????????????????????
?total += i;
}
則執(zhí)行完該程序段后total的值為:( )驼鹅。
A微谓、0?B、1?C输钩、3?D豺型、6
3.執(zhí)行如下程序代碼
int a=0,c=0;
do{???--c;???a=a-1;
??}while(a>0);
??后,C的值是()
A.0???B.1???C.-1??D.死循環(huán)
答案:C A C