程式語言 (Principles of Programming Languages) 2008
教師信箱:jrjiang_a_t_csie.ncu.edu.tw (江振瑞)
助教信箱:cavour_a_t_acnlab.csie.ncu.edu.tw (張少榛) (鍾陳威) (范登凱)
作業繳交:pl2008_a_t_acnlab.csie.ncu.edu.tw
Blackborad System: http://bb.ncu.edu.tw
(程式語言A)
上課時間:Tuesday 15:00~17:50
上課地點:E6-A206
軟體下載:
相關聯結:
授課大綱:
Java語言基礎
- 撰寫第一個Java程式 (Application) (Java01.ppt)
(JDK online
document)
FirstApplication.java(初
學 者撰寫的第一個Java程式)
第
一個應用程式.java(初學者撰寫的第一個全中文Java應用程式)
- 建立程式執行環境 (Install JDK)(JDK online document)(Install MinGW)(Install Jeep4)
- 變數的型別及運算子的使用 (Java03.ppt)(Alg.ppt)
計 算.java(輸入兩個整數,並計算其和、差、積、商及於數結
果)
計算.cs(輸入兩個整數,並計算其和、差、積、商及於數結果)
計算2.java(輸入兩個整數,並計算其和、差、積、商及於數結果)
In-class Homework1: Write a Java application to input a positive integer
n larger than 2 and no larger than 2147483647, and to output the largest prime
less than n. The homework should include the programs and the output results.
- 陣列與迴圈的使用 (Java04.ppt)
每
月天數.java(此程式可顯示出公 元2000年各月份天數)
每月天數.cs(此程式可顯示出公元2000年各月份天數)
foreach
每月天數.java(此 程式可顯示出公元2000年各月份天數)
foreach
每月天數.cs(此程式可顯示出公 元2000年各月份天數)
In-class Homework2: Write a Java application to
deal poker cards into four hands. You should print out the results as follows.
First Hand : S3, S7, S13, H1, H8, H12, D4, D6, D8, D10, C3, C9, C12
Second Hand: ...
Thrid Hand : ...
Fourth Hand: ...
(Hint: Use S, H, D, and C to stand for Spade, Heart, Diamond and Club, respectively.)
The homework should be in MS-Word format to include the program and the output
results.
- ACM-ICPC (ppt)
- ACM-ICPC Example: http://online-judge.uva.es/p/v100/10041.html
(Vito's Family) (Vito.java)
(Vito2.java)
(Vito.cpp)
- ACM-ICPC Example: http://online-judge.uva.es/p/v100/10038.html
(JollyJumper.ppt)
(JollyJumper.cpp)
by a student
In-class Homework3: Rewrtie the JollyJumper.cpp
as a Java program and sumit it to UVA judge. (羅
馬數字 Roman Numbers)
1. Note that the Java program should use the class name: Main
2. You can refer to (Java1.5新特性 JavaE.ppt)
for an easy method of standard input.
- Other ACM-ICPC Examples:
1. http://online-judge.uva.es/p/v101/10194.html
(Football)
2. http://online-judge.uva.es/p/v1/120.html
(Stacks of Flapjacks)
3. http://online-judge.uva.es/p/v100/10037.html
(Bridge)
4. http://online-judge.uva.es/p/v101/10191.html
(Longest Nap)
5. http://online-judge.uva.es/p/v100/10026.html
(Shoemaker's Problem)
6. http://online-judge.uva.es/p/v101/10138.html
(CDVII)
7. http://online-judge.uva.es/p/v101/10152.html
(ShellSort)
- Homework 4: Solve an assigned UVA ICPC sample
problem. You should submit your solution to the PC Judge or UVA Judge for verifying
the correctness. The homework should include a power point file describing
the problem and the solution, a screen shot of UVA Judge-accepted record and
the program source code.
- 流程控制敘述 (Java05.ppt)
Homework5: Write a Java application to input an
integer n and return the largest 'perfect number' no larger than n.
A perfect number is defined as an integer which is the sum of its proper positive
divisors, that is, the sum of the positive divisors not including the number.
The first perfect number is 6, because 1, 2 and 3 are its proper positive
divisors and 1 + 2 + 3 = 6. The next perfect number is 28 = 1 + 2 + 4 + 7
+ 14. Due Date:
March 19, Midnight
Exercise: 設計一Java程式,可輸入縣市別代碼及性別代碼,並自動產生一個正確的身分證字號。
(身分證字號真偽.
java) - Reference:
Quiz-10-24-2006
(with answers)
- 類別與物件 (Java06.ppt)
- 在網頁中使用Java小程式 (Applet)(Java02.ppt)
Homework6: 設計一個Java Applet,此Applet有二個方法成員,可以進行中文金額與10進位數字之轉換:
1.第一個方法成員可以讓使用者在彈出式輸入對話框中輸入介於0到10^9的10進位數字,而在彈出式訊息對話框傳回其對應的中文金額,例如:
102,壹佰零貳;
3456,參仟肆佰伍拾陸;
78900,柒萬捌仟玖佰
註:零壹貳參肆伍陸柒捌玖;拾佰仟萬億;
2.第一個方法成員可以讓使用者在彈出式輸入對話框中輸入中文金額,而在彈出式訊息對話框傳回對應的10進位數字
- 類別庫 (Java07.ppt)
(String 類別的使用等)
- Java 語言中的多媒體 (Java08.ppt)(applet.zip)(LoadImage.html)(LoadAudio.html)(Animation.html)(A2.html)
-
- 繪
圖方法測試.java(此程式可測試各種繪圖的用法)
- 字
型測試.java(此程式可測試各種字型的用法)
- 顏
色測試.java(此程式可測試各種顏色的用法)
- 影
像載入測試.java(此程式可測試影像載入的用法)
- 音
效撥放測試.java(此程式可測試音效撥放)
- 動
畫測試.java(此程式可測試動畫效果)
- 習
題8_1.java(繪製100個10X10大小的方格)
- 習
題8_2.java(繪製彩虹圖案)
- 繪
製方形.java(利用for迴圈敘述畫出10個正方形)
- 繪
製同心方形.java(利用for迴圈敘述畫出10個正方形)
- 繪
製同心圓形.java(利用for迴圈敘述畫出10個正圓形)
- 繪
製同心環.java(利用for迴圈敘述畫出9個同心環)
- 隨
機繪製直線.java(隨機繪製100條直線)
- 動
畫測試1.java(此程式可測試動畫效果)
- 動
畫測試2.java(此程式可測試動畫效果)
- A2.java
- 顯
示字串.java(將字串以紅色20點斜體、藍色30點粗體、綠色40點粗斜體顯示於繪圖區)
- Java1.5新特性 (JavaE.ppt)
Homework 7: Write a Java application
for users to input a sequence of charatcters from standard input (System.in)
for checking if it has balanced brackets like { [ ( < > ) ] }. If so,
output "Balanced Brackets!!"; otherwise, output "Unbalanced Brackets!!". You
are confined to use Stack class, which implements Collection interface, with
the concepts of generics, auto-boxing and auto-unboxing to push in or pop
out an character for the checking.
Hint: Refer to "Java™ Platform, Standard
Edition 6 API Specification" for the usage of Stack class.
- Mouse
- Homework 8: Write a Java applet for users to
input some points for generating their convex hull.
- Bonus homework (for adding
up to 3 points in the final score): Write a Java Applet for users to draw
or fill geometric items in any color, like rectangles, squares, triangles, rhombus (diamonds),
circles, ovals,
lines, arcs, polygons and strings. The applet
should allow users to store and retrieve their drawings. Deadline:
May 20, 2008.
- Homework 9: Write a Java application for users
to input a text file name and a string. Output "not found" if the string does
not appear in the file; otherwise, output all the line numbers and offsets
of the string position.
Java語言進階
Homework 11: 利用Java語 言,寫一個網路爬蟲(crawler)程
式,可以由某個網頁開始,將網頁下載後隨機拜訪網頁中的一個html超連結網頁,並印出該網頁網址,重複上述動作直到碰到無超連結的網頁或碰到重複的網頁 或已瀏覽超過某個數目(如10)的網頁為止。
REF:(
GetPage.java)
- Java SSL Web Server
(ssl0.zip)(JSWServer.java)(JSWServer2.java)
(RFC2616)
Homework 12:利用Java語言,寫一個SSL Web Server,而其首頁則是要求使用者填入信用卡卡號的表單。
-
SMTP, POP3 and JavaMail
(SMTPandPOP3.ppt)(JavaMail.ppt)
pop3 server: pop3.csie.ncu.edu.tw
C/C++ 語言
- Introduction to C language
(ppt)
- C/C++ I/O
(C-IO.ppt)(stdio.zip)
(This part is for reference only, not for exam.)
- Homework13: Write a C or C++ program to input
a Fahrenheit degree to transfer it into Celsius degree
- Array and strng
(陣
列與字串.zip)
- Pointer
(指
標.zip)(Pointers.ppt)
- Homework 15: Write a C or C++ program to implement
a matrix adding function: void matrix_add(int m, int n, int *m1, int *m2,
int *m3) to compute the addition of two m by n matrixes m1 and m2 and put
the computation result in m3 by pointer and array operations. You should
use the following test data: m=2, n=3, m1={{3,2,6},{2,3,8}}, m2={{5,2,0},{3,7,9}}
and should print out the test data and the computation reslut in the main()
function.
- C++ NewTypes (C++NewTypes.ppt) (This
part is for reference only, not for exam.)
- C++ Classes (C++Class.zip)
(Pages 11 to 13 are ruled out, not for exam.)
- Some C++ Features (C++Features.zip)
- Homework 17: Rewrite the Java program in progression.doc
as a C++ program.
- Final Exam (Java, C and C++): 15:00~17:00, June 17, 2008.
- Bonous Program using Java Networking Utilities
(up to 3 points): Examples: FTP program, mailing program, special web crawlers,
web site with server side functions, etc. (Demonstrate to TA before June
23.)
教科書:
參考書:
- Robert W. Sebesta, "Concepts of Programming Languages," 7/e, Pearson
Education, 2005.
- Steven S. Skiena and Miguel Revilla, "Programming Challenges," Elsevier,
2003.
- C/C++程式設計入門與應用, 吳權威、王曉慧 編著, 網奕資訊 出版
- Java2程式設計入門與應用, 吳權威、王曉慧 編著, 網奕資訊 出版
- 精彩Java2程式設計, 吳逸賢、吳目誠 編著, 網奕資訊 出版
- 精彩JavaScript程式設計, 吳逸賢、王曉慧 編著, 網奕資訊 出版
- Java網際網路程式設計, 黃嘉輝 著, 文魁出版社
- JSP動態網頁入門實務, 位元文化 編著, 文魁出版社
- Java網路程式設計, 顏春煌 編著, 旗標出版社
評分方式:
-
PHP
-
Perl
-
Python
-
LISP
-
Prolog
-
Basic
-
Pascal
- ICPC programs (3 problems in one week's report)
- Homeworks (3 problems in one week's report)
其他相關鏈結: