102高考資料處理 Java - 高考

By Daniel
at 2013-07-18T11:19
at 2013-07-18T11:19
Table of Contents
: 三、請問執行下列JAVA 程式碼後的結果為何?請繪製此程式的流程圖。(20 分)
: 01. public class ShowClass {
: 02. public static void main( String[] args )
: 03. {
: 04. int row = 4;
: 05. int column;
: 06.
: 07. while ( row >= 1 )
: 08. {
: 09. column = 1;
: 10.
: 11. while ( column <= 5 )
: 12. {
: 13. System.out.print( row % 2 == 1 ? "<-" : "->" );
: 14. ++column;
: 15. } // end while
: 16.
: 17. --row;
: 18. System.out.println();
: 19. } // end while
: 20. } // end main
: 補習班公佈的流程圖不才是看得懂,而補習班的輸出結果為:
: ->->->->->
: <-<-<-<-<-
: ->->->->->
: <-<-<-<-<-
: 因為本身非資訊背景,所以想請教各位程式的
: 13. System.out.print( row % 2 == 1 ? "<-" : "->" );
: 列2是否等於1?甚麼意思?
row是第4行宣告的變數(值為4)
row%2==1表示4(變數row)除以2的餘數是否為1,
是就是問號(?)後面第一項("<-"),否的話就是第二項("->")
: 14. ++column;
: 它跟C語言的前置模式的用法是一樣的嗎?
是的~~一樣
: 17. --row;
: 原因同上
也一樣~
小弟本身也不強~希望這樣回答能幫助到你~
--
Tags:
高考
All Comments

By Hedy
at 2013-07-19T11:42
at 2013-07-19T11:42

By Dinah
at 2013-07-23T04:25
at 2013-07-23T04:25
Related Posts
102高考資料處理 Java

By James
at 2013-07-18T11:09
at 2013-07-18T11:09
102 高考貨銀 第一題

By Agnes
at 2013-07-18T10:15
at 2013-07-18T10:15
法科推薦的教科書

By Rosalind
at 2013-07-18T00:29
at 2013-07-18T00:29
三等(高考)農業技術 or 四等(普考)農業

By Queena
at 2013-07-17T21:08
at 2013-07-17T21:08
三等(高考)農業技術 or 四等(普考)農業

By Christine
at 2013-07-17T19:56
at 2013-07-17T19:56