JAVA 96郵政試題 - 考試

By Skylar DavisLinda
at 2013-03-07T09:01
at 2013-03-07T09:01
Table of Contents
※ 引述《dragpin ( )》之銘言:
11.執行下列程式Test1後,將列印 "12" 次Hello
public class Test1 {
public static void main (String[] args){
for(int i=1;i<5;i++)
for(int j=6;j>2;j--) <<<題目應該是這樣
for(int k=i;k<3;k++)
system.out.println("Hello");
}
}
為什麼是12次呢??? 先謝謝各位高手解答。
一般來說For迴圈用圖解會蠻好理解的(小量的話拉^^")
┌───────────┬───────┐
i│1 │2 │
├──┬──┬──┬──┼─┬─┬─┬─┤
j│6 │5 │4 │3 │6 │5 │4 │3 │
├──┼──┼──┼──┼─┼─┼─┼─┤
k│1│2│1│2│1│2│1│2│2 │2 │2 │2 │
└──┴──┴──┴──┴─┴─┴─┴─┘
共計12次的Hello
以上有錯請糾正~
--
11.執行下列程式Test1後,將列印 "12" 次Hello
public class Test1 {
public static void main (String[] args){
for(int i=1;i<5;i++)
for(int j=6;j>2;j--) <<<題目應該是這樣
for(int k=i;k<3;k++)
system.out.println("Hello");
}
}
為什麼是12次呢??? 先謝謝各位高手解答。
一般來說For迴圈用圖解會蠻好理解的(小量的話拉^^")
┌───────────┬───────┐
i│1 │2 │
├──┬──┬──┬──┼─┬─┬─┬─┤
j│6 │5 │4 │3 │6 │5 │4 │3 │
├──┼──┼──┼──┼─┼─┼─┼─┤
k│1│2│1│2│1│2│1│2│2 │2 │2 │2 │
└──┴──┴──┴──┴─┴─┴─┴─┘
共計12次的Hello
以上有錯請糾正~
--
Tags:
考試
All Comments

By George
at 2013-03-12T04:44
at 2013-03-12T04:44
Related Posts
關於公務員的兩三事

By Callum
at 2013-03-07T09:00
at 2013-03-07T09:00
從今天開始老娘不得不信神了(上榜文無誤)

By Ethan
at 2013-03-07T08:52
at 2013-03-07T08:52
普考任職n年後考上高考,月薪與年資的問題

By Ursula
at 2013-03-07T08:21
at 2013-03-07T08:21
101地特三等電力工程上榜心得 (台中市)

By Thomas
at 2013-03-07T05:28
at 2013-03-07T05:28
101地特台中四等一般民政

By Oliver
at 2013-03-07T03:54
at 2013-03-07T03:54