下面程序的输出结果是 ( )public class ex2{ public static void main(String []args) { for(int cnt=1;cnt<=10;cnt++)

admin2010-02-22  23

问题 下面程序的输出结果是    (    )public class ex2{    public static void main(String []args)    {        for(int cnt=1;cnt<=10;cnt++)        {            if(cnt<=5)                continue;            System.out.print(cnt+"");        }    }}

选项 A、1 2 3 4
B、6 7 8 9
C、1 2 3 4 6 7 8 9 10
D、6 7 8 9 10

答案8

解析 本题考查的是for循环和if语句的混合使用。而if语句后跟的是continue,它的意思是满足if语句,则不执行下一条语句,也不跳出循环,而是继续执行。所以本题中小于等于5的数都没输出,只输出大于5的数,即不满足if语句的数。
转载请注明原文地址:https://jikaoti.com/ti/IkH0FFFM
0

随机试题
最新回复(0)