Java class 2010.10.22. Outline for loop while loop do while loop How to choose? Nested loop.

Slides:



Advertisements
Similar presentations
SQL1-ch2 限制和排序資料. 考古題題號  80 題: 27 、 51  140 題: 23 、 58 、 70.
Advertisements

 for loop  while loop  do while loop  How to choose?  Nested loop  practice.
LOOP / REPETITION while loop. for loop do/while loop We assume that loops are not meant to be infinite. That is, there should always be a way out of the.
: Arrange the Numbers ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11481: Arrange the Numbers 解題者:李重儀 解題日期: 2008 年 9 月 13 日 題意: 將數列 {1,2,3, …,N}
Introduction to Java Programming Lecture 13 Classes I OO Programming.
國立臺北科技大學進修部推廣教 育中心 生活美語會話 課程 英語課程說明 陳韻如 Melody.  課程目的:學生能夠使用簡單的英文以及在 一般英文會話中能夠自然應對並啟發學習英文 興趣  培養學生的聽、說、讀、寫基本能力,且琢 磨於文法、句型、字彙上的練習及應用使學生 透過老師的帶領,進行文化的體驗、發音的矯.
期末專題 - 吊人頭遊戲 第 35 組 組員 : 電機系 49841XXXX XXX 電機系 49841OOOO OOO.
矩陣乘法 實作矩陣乘法 利用 threads 來加速運算速度 – Matrix1 row x Matrix2 column = Ans (x,y) Matrix 1Matrix 2Answer.
1 第一章 Word 的基本觀念 內容概要: Word 的特色 啟動與離開 Word 的方法 滑鼠游標與外型的介紹 基本操作 Word 視窗法則 使用 Word 遭遇問題時, 應如何利用軟體特 性而獲得輔助解說.
 Pearson Education, Inc. All rights reserved Formulating Algorithms: Sentinel- Controlled Repetition Example: – 計算任意數目個學生的平均成績 Sentinel-controlled.
: Road Construction ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 10724: Road Construction 解題者:徐文宏 解題日期: 2011 年 4 月 20 日 題意:給一個座標圖 (-1000~1000)
Graph V(G 1 )={0, 1, 2, 3, 4, 5, 6, 7, 8, 9} E(G 1 )={(0, 2), (0, 3), (1, 4), (2, 3), (2, 5), (2, 6), (3, 6), (3, 7), (4, 7), (5, 6), (5,
JAVA 程式設計與資料結構 第二章 JAVA 程式基本概念及操作. 第一個程式 /* * 這是第一個程式 (FirstP.java) */ class FirstP{ public static void main(String args[]){ System.out.println("Whatever.
Multidimensional Array Outline Two-Dimensional Arrays Lengths of Two-Dimensional Arrays Multidimension Arrays [Sample code]
4-1 循序結構 4-2 選擇結構 4-3 重複結構 4-4 其他迴圈相關敘述 4-5 本章綜合練習
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
 Pearson Education, Inc. All rights reserved break and continue Statements Break and continue statements – Alter flow of control break.
OS 期中檢討 2005/11/30. Problem 1 課本上有答案 (e) 指出一定時間內完成 (f) 除了 many-to-many ,還有 1-to-1.
南投縣社區大學 Excel 實務應用入門 講師 : 林泉成
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
第 5 章 深入 Response 物件 製作. 網頁的轉向與強制輸出 - 讓網頁轉彎的 Redirect 敘述 運用 Response 物件的 Redirect 方法,將瀏覽器顯 示的網頁,導向至其他網頁,語法如下: Response.Redirect 網頁路徑與名稱 此網頁路徑與名稱  若是導向到同一台.
:Problem D: Bit-wise Sequence ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10232: Problem D: Bit-wise Sequence 解題者:李濟宇 解題日期: 2006 年 4 月 16.
24-6 設定開始與結束場景中的 程式 最後我們要替這個遊戲收個尾, 幫它把開始 的等待畫面跟結束畫面處理一下。
第 6 章 迴圈結構 6-1 計數迴圈 6-1 計數迴圈 6-2 條件迴圈 6-2 條件迴圈 6-3 巢狀迴圈 6-3 巢狀迴圈 6-4 While/End While 迴圈 6-4 While/End While 迴圈 6-5 跳出與繼續迴圈 6-5 跳出與繼續迴圈 6-6 錯誤處理 6-6 錯誤處理.
Chapter 20 塑模動態觀點:狀態圖 Statechart Diagram. 學習目標  說明狀態圖的目的  定義狀態圖的基本記號  展示狀態圖的建構  定義活動、內部事件及遞延事件的狀態 圖記號.
Hung-Hsiang WuWindows Processing Design1 Chapter 3 基本觀念 變數宣告與型態 特殊運算子符號 字串與數值的轉換 類別與物件的觀念 建立新的專案 WinMain 程式進入點 Include Header File.
: Happy Number ★ ? 題組: Problem Set Archive with Online Judge 題號: 10591: Happy Number 解題者:陳瀅文 解題日期: 2006 年 6 月 6 日 題意:判斷一個正整數 N 是否為 Happy Number.
1 Netlibrary 電子書 Netlibrary 創始於 1998 年,是世界知名的電子書資 料庫,提供 450 多家出版社所出版近 100,962 ( 止)本的電子書,且以每月 2,000 本的 速度增加中。其中 80% 屬於學術性圖書,其餘 20% 一般圖書, 90% 以上為.
 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
Outline Overloading Methods The Scope of Variables The Math Class Floating point Format [Sample code] TestMethodOverloading.java.
Fugacity Coefficient and Fugacity
: Robot Motion ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: : Robot Motion 解題者:鄭昀旻 解題日期: 2009 年 5 月 20 日 題意:有一機器人會從網格的上(N)方進入, 依網格上之E、W、S、N之指令來行走,題目.
4 堆疊與佇列 4.1 前言 四種基本的資料結構 (可儲存資料的容器) 陣列 (Array)、串列(List): 最基本
: Beautiful Numbers ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11472: Beautiful Numbers 解題者:邱經達 解題日期: 2011 年 5 月 5 日 題意: 若一個 N 進位的數用到該.
資料結構實習-二.
Visual Basic 簡介 Visual Basic 基礎語法 東海大學物理系‧施奇廷 《程式設計》
Visual Basic 簡介 Visual Basic 基礎語法 東海大學物理系‧施奇廷 《程式設計》
File I/O 範例講解 授課:林哲嘉 日期: 2009/04/29. 範例:上機考第三題 Add 部分 1. 將檔案的資料顯示在畫面 2. 將要加入檔案加到資料的尾端.
資料結構實習-十 Binary Tree Traversal.
Network Analyzer For Ethereal. 基本設備 Hardware pc network card can connect INTERNET Software OS Winpcap Ethereal.
: Function Overloading ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11032:Function Overloading 解題者:許智祺 解題日期: 2007 年 5 月 8 日 題意:判對輸入之數字是否為.
Client Messages 1 訊息作用 LOAD 載入整個課程 NEXT 依活動定義順序的下一個活動 PREVIOUS 依活動定義順序的前一個活動 COMPLETE 完成目前瀏覽的活動 QUIT 離開課程.
: Help My Brother ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11033: Help My Brother 解題者: 呂明璁 解題日期: 2007 年 5 月 14 日.
5 重複迴圈 5.1 增減運算符號 增量運算符號 減量運算符號
Introduction to Java Programming Lecture 8 Flow Control : while do-while and for loops.
第 3 章 學習 80x86 指令. 本章提要 80x86 的指令格式與分類 搬動資料的指令群 算術指令群、邏輯運算指令群 平移與旋轉指令 流程控制與旗標控制指令 字串處理指令群 I/O 指令群、 CPU 控制指令群.
第 6 章 迴圈結構 6-1 計數迴圈 6-1 計數迴圈 6-2 條件迴圈 6-2 條件迴圈 6-3 巢狀迴圈 6-3 巢狀迴圈 6-4 While/End While 迴圈 6-4 While/End While 迴圈 6-5 跳出迴圈 6-5 跳出迴圈 6-6 VB.NET 的錯誤處理 6-6 VB.NET.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
Java class Outline Defining a method Calling Method Passing parameters [Sample code] TestMethod.java 、 TestMethod2.java 、 GCD.java 、 prime.java.
Visual C++重點複習.
資料結構實習-六.
第 5 章 選擇控制項與條件敘述 5-1 結構化程式設計 5-1 結構化程式設計 5-2 關係與邏輯運算子 5-2 關係與邏輯運算子 5-3 簡單的條件敘述 5-3 簡單的條件敘述 5-4 選擇控制項 5-4 選擇控制項 5-5 巢狀條件敘述 5-5 巢狀條件敘述 5-6 多選一條件敘述 5-6 多選一條件敘述.
11 Ch05 遞迴 淡江大學 周清江 1. 2  遞迴函數乃是一個自己反覆呼叫自己的函數  一個典型的遞迴演算法 n! = n * (n-1)! = n * (n-1) * (n-2)! = n * (n-1) * (n-2) * (n-3)! = … = n * (n-1) * (n-2)
C 語言練習題 2010/12/2. C 程式的格式 一、 C 程式的格式 (1). /* …. */ 是 C 程式的 ______ main() 的內容是由敘述構成的 (2). 敘述要以 __ 為結束符號 (3). 變數、函數都要做 ____ 的宣告 (4). ‘=’ 是 ____ 用的算符 (5).
 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
著作權所有 © 旗標出版股份有限公司 第 14 章 製作信封、標籤. 本章提要 製作單一信封 製作單一郵寄標籤.
VHDL語法(3).
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷
程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷
說說看你喜歡的運動. 1. 第七課 短期運動營 2 聽力練習 : 放課文 DVD, 並回答問題 3.
Chapter 4 – C Program Control
1 Chapter 10 Additional Control Structures and Exceptions.
A Quick Start of C Introduction. 2 Terminology Program 程式 Programming language 程式語言 Code 程式碼 Compiler 編譯器 –cc, GNU gcc, g++,… –IDE: MS Visual C++, Dev.
While ( number
Chapter 4 Repetition Statements (loops)
Alice in Action with Java
Outline Altering flow of control Boolean expressions
Three Special Structures – Case, Do While, and Do Until
Presentation transcript:

Java class

Outline for loop while loop do while loop How to choose? Nested loop

for loop EX: for ( i=0 ; i<=100 ; i++ ) // 迴圈條件運算式 { // 迴圈內的動作 ; }

迴圈內的動作 進入迴圈 true false 離開迴圈 迴圈條件運算式

while loop EX: int count=0; while ( count<100 ) { System.out.println(”Hello!”); count++; } p.s count 從 0 累加到 99

loop- continuation condition? Statement(s) (loop body) false true count=0 (count < 100) ? System.out.println(“Hello!”); count++;

練習 : 用 for loop 以及 while loop, 寫九九乘法表 格式 :

do while loop EX: int count=0; do { System.out.println(”Hello!”); count++; } while ( count<100 );

loop- continuation condition? Statement(s) (loop body) false true count=0 (count < 100) ? System.out.println(“Hello!”); count++;

Pretest & Posttest loop 先測迴圈 : while 、 for The condition is checked before the loop body is excuted. 後測迴圈 : do while The condition is checked after the loop body is excuted.

How to choose? A for loop may be used if the number of repetitions is known in advance. A while loop may be used if the number of repetitions is not fixed. A do while loop can be used to replace a while loop if the loop body has to be executed before the condition is tested. 課本 p.152

Nested( 巢狀 ) loop for { ……. for { ……. } 課本 p.153

回家看 : p.152 ~ p.153