三、請問執行下列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?甚麼意思?
14. ++column;
它跟C語言的前置模式的用法是一樣的嗎?
17. --row;
原因同上
這三行明確的意思?(感覺它是一個字串的二維陣列,但是這三行不懂,無法下結論。)
由於考試有時會考程式題,順便請問各位,市面上有無針對初學者或非資訊背景的C語
言、Java程式簡單易懂的入門書(感覺只憑補習班上的課是不夠的),不才只想把基本的
指令語法搞懂可應付考試就好,有的話也煩請推薦一下。
以上問題再麻煩各位了,感謝!
--
All Comments