Quiz #3. 6.Show the final output of the program execution given in Fig.1. public class A{ int x=1;  實體變數 public int m01(int y){ int x = 3;  區域變數 return.

Slides:



Advertisements
Similar presentations
Homework - Chapter 03 Solution.
Advertisements

FCU, Department of ECE, IC Design Research Lab. TEL: # 4945 Pre-SIm , Post-Sim.
Divide-and-Conquer. 什麼是 divide-and-conquer ? Divide 就是把問題分割 Conquer 則是把答案結合起來.
Chapter 10 馬可夫鏈 緒言 如果讀者仔細觀察日常生活中所發生的 諸多事件,必然會發現有些事件的未來 發展或演變與該事件現階段的狀況全然 無關,這種事件稱為獨立試行過程 (process of independent trials) ;而另一些 事件則會受到該事件現階段的狀況影響。
Introduction to Java Programming Lecture 13 Classes I OO Programming.
建立使用案例敘述 --Use Case Narrative
Mathcad 基本認識 再mathcad中等於(=)的符號有區分為三種: 第一種:冒號等於(:=)是代表我們要定義ㄧ個參數
3Com Switch 4500 切VLAN教學.
What is static?. Static? 靜態 ? class Test { static int staticX; int instanceX; public Test(int var1, int var2) { this.staticX = var1; this.instanceX =
1 第一章 Word 的基本觀念 內容概要: Word 的特色 啟動與離開 Word 的方法 滑鼠游標與外型的介紹 基本操作 Word 視窗法則 使用 Word 遭遇問題時, 應如何利用軟體特 性而獲得輔助解說.
邏輯設計 題目:3_8解碼器 姓名:李國豪 學號:B09322001.
建立靜態資料成員 關鍵字: static 靜態資料成員不屬於特定物件,而是該類物件 所共同擁有的,可做為類別範圍裡的靜態變數。
: OPENING DOORS ? 題組: Problem Set Archive with Online Judge 題號: 10606: OPENING DOORS 解題者:侯沛彣 解題日期: 2006 年 6 月 11 日 題意: - 某間學校有 N 個學生,每個學生都有自己的衣物櫃.
第一章 變數、常數及資料型態. 變數 C 程式語言的變數名稱 第一個字必須是英文字母或底線 (_) 之後可以是數字, 英文字母或底線 (_) 不可以是保留字 例: Num (Ο) _score (Ο) C&C (X) 8num (X)
JAVA 程式設計與資料結構 第二章 JAVA 程式基本概念及操作. 第一個程式 /* * 這是第一個程式 (FirstP.java) */ class FirstP{ public static void main(String args[]){ System.out.println("Whatever.
第 13 章 常數、靜態成員與朋友關 係 13-1 常數物件與成員 13-1 常數物件與成員 13-2 物件成員與巢狀類別 13-2 物件成員與巢狀類別 13-3 靜態成員資料與函數 13-3 靜態成員資料與函數 13-4 朋友關係 13-4 朋友關係.
1. 假設以下的敘述為一未提供 “ 捷徑計算 ” 能力的程式段,試用程 式設計的技巧,使此敘述經此改 寫的動作後,具有與 “ 捷徑計算 ” 之 處理方法相同之處理模式。 if and then E1 else E2 endif.
1 Introduction to Java Programming Lecture 7 Flow Control : Boolean expressions and the if statement.
第 18 章 名稱空間與例外處理 18-1 名稱空間 18-1 名稱空間 18-2 例外處理 18-2 例外處理.
VHDL 邏輯設計 題目:一對十六解多工器 題目:一對十六解多工器 姓名:李國豪 姓名:李國豪 學號:B09322001 學號:B09322001.
南投縣社區大學 Excel 實務應用入門 講師 : 林泉成
第 7 章 程序與函數 7-1 模組化程式設計 7-1 模組化程式設計 7-2 VB.NET 的程序與函數 7-2 VB.NET 的程序與函數 7-3 程序與函數的變數範圍 7-3 程序與函數的變數範圍 7-4 VB.NET 常用的內建函數 7-4 VB.NET 常用的內建函數 7-5 遞迴函數 7-5.
Introduction to Java Programming Lecture 5: Using Java Classes : String & Math Spring 2009.
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
Chapter 13 塑模靜態觀點:物件圖 Static View : Object Diagram.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
: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 錯誤處理.
Introduction to Java Programming Lecture 10 Array I Declaring, Creating, and Initializing Arrays.
Chapter 20 塑模動態觀點:狀態圖 Statechart Diagram. 學習目標  說明狀態圖的目的  定義狀態圖的基本記號  展示狀態圖的建構  定義活動、內部事件及遞延事件的狀態 圖記號.
類別函式庫. Java Bean 一個單獨的 AWT 元件都是一個 bean. Java Bean 也有一個 bean 的 class 可繼承, 但是並不強 迫一定要繼承. Bean 的結構 Properties 屬性 : 描述 bean 的屬性 如顏色, 大小,label 等. 透過一對 methods.
選舉制度、政府結構與政 黨體系 Cox (1997) Electoral institutions, cleavage strucuters, and the number of parties.
: Little Red Riding Hood ★★★☆☆ 題組: Contest Volumes Archive with Online Judge 題號: 11067: Little Red Riding Hood 解題者:陳明凱 解題日期: 2008 年 3 月 14 日 題意:
1 單元四 個人化服務 Web of Science 利用指引. 2 個人化服務 Sign In 登入 My EndNote Web 使用 EndNote Web 者可登入 My Citation Alert 查看或修改先前設定的引用通告 My Saved Searches 查看或更改先前儲存過的檢索.
第十章 再論結構. 指標與結構的關係 /* File name: ex10-1a.c */ #include int main() { struct student { char *name; int score; }; struct student st= {"Brian", 97}; struct.
: Ahoy, Pirates! ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11402: Ahoy, Pirates! 解題者:李重儀 解題日期: 2008 年 8 月 26 日 題意:有一個海盜島有 N 個海盜,他們的編號 (id)
1-6 動畫的文件屬性 舞台是動畫實際播放的畫面, 所以舞台的大 小與長寬比例對將來動畫的呈現有很大的 影響。 Flash 預設的舞台尺寸是 550 Pixels × 400 Pixels, 背景為白色, 如果要更改舞台大小與 背景色, 請執行『修改 / 文件』命令, 開啟文 件屬性 (Document.
資料結構實習-一 參數傳遞.
第六章 陣列.
Hung-Hsiang WuWindows Processing Design1 Chapter 4 簡單視窗程式 表單與標籤的屬性 按鈕與編輯的屬性 設計簡單的應用程式 表單常用事件 一般鍵盤及滑鼠常見的事件 表單視窗間的呼叫 表單間資料傳送應用 專案選擇設定.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
: Beautiful Numbers ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11472: Beautiful Numbers 解題者:邱經達 解題日期: 2011 年 5 月 5 日 題意: 若一個 N 進位的數用到該.
第 9 章 TSR 程式基本教練. 本章提要 TSR 程式 以熱鍵 (Hot key) 叫用 TSR 程式 Clock 中斷 int 08h 、 int 1ch DOS reentrant 的問題 有用的 TSR 程式.
函式 Function Part.2 東海大學物理系‧資訊教育 施奇廷. 遞迴( Recursion ) 函式可以「呼叫自己」,這種動作稱為 「遞迴」 此程式的執行結果相當於陷入無窮迴圈, 無法停止(只能按 Ctrl-C ) 這給我們一個暗示:函式的遞迴呼叫可以 達到部分迴圈的效果.
資料結構實習-二.
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
時間序列 Chap7 1 Chap 7 Decomposition method 4 components : Trend (TR t ) :長期向上或向下的移動趨勢 Seasonal variation (SN t ) :以年為基礎的變動原型 Cycle (CL t ) :在 2 到 10 年中向上或向下的改變.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
5 重複迴圈 5.1 增減運算符號 增量運算符號 減量運算符號
INTRODUCTION TO MATLAB SHAWNNTOU. What Is MATLAB? MATLAB® is a high-performance language for technical computing. MATLAB® is a high-performance language.
: Problem E Antimatter Ray Clearcutting ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11008: Problem E Antimatter Ray Clearcutting 解題者:林王智瑞.
第 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.
09610CS_ 校園授權軟體下載與安裝 講師 : 張智宏. 登入校務資訊系統 校園軟體下載.
Miscellanea Switch Bitwise operations ?,. break; continue; (example) (example) do { a = getc(stdin); if (a=='q') break; else if (a=='c') continue; n++;
Introduction to Java Programming Lecture 12 Method Benefits, Declaring, and Calling Methods.
函式 Function 東海大學物理系‧資訊教育 施奇廷. 函式簡介 當程式越來越大、越複雜時,程式的維護、 除錯會變得更困難,此時必須引入函式來 簡化程式或將程式分段,將程式重複的部 分改寫為函式,將程式「模組化」 這種作法有下列優點:節省程式發展的時 間、邏輯容易瞭解、程式容易除錯、可分 工合作完成程式.
Visual C++重點複習.
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2008.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2010.
What is static? CS340100, NTHU Yoshi. Static? 靜態 ? class Test { static int staticX; int instanceX; public Test(int var1, int var2) { this.staticX = var1;
Introduction to Java Programming Lecture 16 Super and Sub Classes.
著作權所有 © 旗標出版股份有限公司 第 14 章 製作信封、標籤. 本章提要 製作單一信封 製作單一郵寄標籤.
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2009.
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷
南台科技大學 資訊工程系 Arduino 與電腦端互動設計之三 報告人:洪賢麟 指導老師:李育強 日期: 2013/11/20 報告人:洪賢麟 指導老師:李育強 日期: 2013/11/20.
Activity Networks AOV 網路 AOE 網路. AOV 網路 (Activity on Vertx Networks)  為了表示一件工作中,各子工程間的先後 關係,我們可以利用有向圖中的有向邊代 表事情進行的順序,位於一條有向邊終點 的事件必須要等待起點的事情完成後,才 可以進行。
H.264/AVC code tracing REPORT Group 1. no Tsao.
Presentation transcript:

Quiz #3

6.Show the final output of the program execution given in Fig.1. public class A{ int x=1;  實體變數 public int m01(int y){ int x = 3;  區域變數 return x+y;  此 X 使用區域變數 } public int m02(int y){ return x+y;  此 X 使用實體變數 } public void main(){ int y; int z; y=x+m01(3);  y=1+m01(3)=1+(3+3)=7 x=10-m01(9);  此 X 使用實體變數∴改變的值為一開始宣告的 x 的值  x=10-m01(9)=10-(3+9)=10-12=-2 z=y+m02(22);  z=7+m02(22)=7+(-2+22)=27 println(x, y, z); } Answer :

7.Show the final output of the program execution given in Fig.2. public class A{ int x=1; public int m01(int y){ if (y%2==0)  如果 y 是偶數的話, return x+y {return x+y} else  如果 y 是奇數的話, return y*2 {return y*2} } public void main(){ int i, s, t; s=0; i=1; while (i =-10){  當 -10≤i≤25 跑 while 裡的指令 s=s+m01(i);  當 i 是偶數 return x+i  當 i 是奇數 return i*2 t=s%3;  依 t mod 3 的結果選擇執下列其中之一 if (t==0){i=i-1}; if (t==1){i=i+2}; if (t==2){i=i+3}; } println(s); println(i); } Answer :

8.How many multiplication (*) and addition (+) are performed respectively when executing the program given in Fig.2. public class A{ int x=1; public int m01(int y){ if (y%2==0)  如果 y 是偶數的話,這裡會使用一次 ”+” {return x+y} else  如果 y 是奇數的話,這裡會使用一次 ”*” {return y*2} } public void main(){ int i, s, t; s=0; i=1; while (i =-10){ s=s+m01(i);  這裡會使用一次 ”+”  m01 裡則依奇 / 偶數,使用 ”*” 或 ”+” t=s%3; if (t==0){i=i-1}; if (t==1){i=i+2};  這裡會使用一次 ”+” if (t==2){i=i+3};  這裡會使用一次 ”+” } println(s); println(i); } Answer : 44 次 ”+” 9 次 ”*”

9.Show the final output of the program execution given in Fig.3 public class A{ int x=1; public void main(){ int s,t; int i,j,k; s=0; i=1; K=0; while (i<=10){  當 i≤10 跑 while 裡的指令 for (j=1;j<=i;j++)  初始 j=1 ;當 j ≤i 跑 while 裡的指令 { while (k<=(i+j))  當 k ≤ (i+j) 跑 while 裡的指令 { s=s+i+j; k=k+1; } i=i+3;  當 for 結束後,更新 i (i=i+3) } println(s); } Answer : 216

10.How many addition (+) are performed when executing the program given in Fig.3. public class A{ int x=1; public void main(){ int s,t; int i,j,k; s=0; i=1; K=0; while (i<=10){ for (j=1;j<=i;j++)  這裡會執行一次 ”+” { while (k<=(i+j))  這裡會執行一次 ”+” { s=s+i+j;  這裡會執行二次 ”+” k=k+1;  這裡會執行一次 ”+” } i=i+3;  這裡會執行一次 ”+” } println(s); } Answer : 110

11.Show the activity diagram for the main( ) method given in Fig. 3.

Quiz #4

4 、 Assume in a main(), two variables are instantiated as class B and C objects. Show the output after executing method “ m01 ” respectively. public class A{ private int x=1; public int m01(int y){ return x+y; }}… public class B{ public x=3; public int m01(int y){ A x = new A(); println(x.x); return y }}… public class C{ public x=5; public int m01(int x){ A z = new A(); println(z.m01(10)); println(this.x); return y }}… 私有成員 “this” 表示「目前這個物件」