Integrated exercises III
(総合演習 III)
Computing Practice I
14th lecture, July 12, 2018
http://www.sw.it.aoyama.ac.jp/2018/CP1/lecture14.html
Martin J. Dürst
© 2005-18 Martin
J. Dürst 青山学院大学
Today's Schedule
- Remaining Schedule
- About last week's test
- About last week's exercises
- Today's exercises
テストなし、ログイン不要
ログインした学生は授業開始前にサインオフすること
Remaining Schedule
- July 20: Integrated exercises IV
- July 27, 14:50-16:15:
Term final exam (85 minutes)
- Added style switch (to show example solutions) to all past exams
Programming Contest
- Most famous student programming contest: ACM ICPC
(Association of Computing Machinery International Collegiate Programming
Contest)
- Some exercises from this contest (e.g. 1401)
- This year's Japanese
preliminary was held last Friday (July 6th)
- Two teams from Aoyama Gakuin University participated
- One team qualified for next round (Yokohama in December)
- Let's participate in next year's preliminary (and finals!)
(for example, start solving past problems in fall term)
Last Week's Exam
- Maximum: 102 points
- Average: 52.8 points
- Best result: 94 points
- Worst result: 14 points
If you have less than 40 points, please think very seriously how you can
improve.
Exams will be handed back after this lecture.
Results of Previous Exercises
|
1301 |
1302 |
1303 |
1304 |
100 points |
59 |
20 |
4 |
4 |
60 points |
35 |
62 |
36 |
31 |
errors |
3 |
3 |
11 |
2 |
not submitted |
3 |
15 |
49 |
63 |
Total of problems solved: 4 problems: 19 students, 3 problems: 26 students,
2 problems: 45 students, 1 problems: 7 students, 0 problems: 3 student
Number of students who did not complete a single problem before 18:30: 36
students
Important Points for Application Exercises
- DRY! DRY!! DRY!!!
- Prefer data over code
(Example: Use initialization instead of functions)
- Data structures matching problem structure
(arrays, structures, combinations of arrays and structures)
- Easy to understand variable names (not just
a, b, c,
...)
- If labels are needed (e.g. "beef", "shrimp",...), make them part of the
data
- Check which data needs to be kept across which loops
- Don't forget the basics (e.g. initialization!)
Selection of Data Structures (Example: 1303)
Data across multiple trials: none
Data common to all investment plans: duration, interest rate ⇒ single
variables
Number of investment plans: Maximum 20 ⇒ array
Data per investment plan: initial investment, sales profit, operating
expenses, net revenue, net present value, plan number ⇒
struct
Function vs. Initialization (Example: 1304)
Using functions:
int shrimp(int protein,int calcium)
{
int price;
price = protein+calcium;
if (price>=20) return price-20;
else return 0;
}
Using initialization:
#define FOODS 8
#define NUTRIENTS 5
typedef struct { int nutrient[NUTRIENTS]; int price; } Food;
int main(void)
{
Food foods[FOODS] = { { { 1, 1, 0, 0, 0}, 22 },
{ { 0, 1, 1, 0, 0}, 20 },
...
};
...
}
応用課題演習 III
今日出される問題の内、最低一問を時間内に提出、できない場合は必ず居残り、宿題を含め最低二問を完成すること
締切は全部 7月16日 (月曜日)
- 1401: カードのゲーム (複数回)
- 1402: 暗号化 (バイナリファイル入出力の応用)
- 1403: 自動販売機: 他国の紙幣構造 (例: 25¢ 硬貨)
にも簡単に対応可能で DRY な設計!
- 1404: 単語の統計
解く順番は自由が、解き始めた問題は完成 (1401
からの順で推薦)
入力は問題文で説明した範囲内に限定
(エラーチェックは不要)
解け方 (アルゴリズム) は (紙などで)
例を作って実験してみる
Q&A フォーラムの活用! 題名に注意!
(問題文の詳細や解き方についての質問も勿論可能)
次回への準備
- 足りない演習問題の完成、提出
- 復習、期末試験の準備