計算機実習 I
第一回 (2016 年 4 月 7日)
http://www.sw.it.aoyama.ac.jp/2016/CP1/lecture1.html
Martin J. Dürst
duerst@it.aoyama.ac.jp
O 棟 529 号室
テュールスト
マーティン ヤコブ

© 2005-16 Martin
J. Dürst 青山学院大学
授業前の準備
  - 授業開始までにログイン
- ブラウザで http://moo.sw.it.aoyama.ac.jp へ移動、ログイン
 
- そのままに
 
Today's Schedule
  - Overall explanations
- Moodle: Explanations and setup
- Minitest
- Lecture
- Explanation of exercise environment
- Exercises
 
Presentation of Teaching Staff
  - 松原 俊一 (助教、総括)
- 長谷川 大 (助教、一列目担当)
- 磯山 直也 (助教、二列目担当)
- 吉田 武史 (助教、三列目担当)
- 盛川 浩志 (助教、四列目担当)
- 塚本 健太 (山口研 M2, TA)
- 村尾 日向子 (鷲見研 M2, TA)
- 遠山 雄 (山口研 M2, TA)
- 佐々木 柾人 (Dürst 研 M2, TA)
- 苅宿 航太 (Dürst 研 M1, TA)
 
授業の位置づけ
  - 情テク必修、EJ 科目
- 大学の一年は「ゆっくり慣れる」
- 大学の二年は「本業の基礎を確実に」
- プログラミングが IT の中心技能
- この授業で本格的にプログラミングを勉強
- これからの授業、演習、卒論、就職などに必ず役立つ
 
約束事
  - 時刻通りログイン済み
- 全員完走 (発展問題を抜く)
- 独力・独走
- 一人一質問毎
- プリントなどへの書き込み
- 私語禁止
- 飲食禁止
- 通路解放
- 脱帽
 
独力・独走の約束
  - 二人以上一緒に問題を解くのは独走ではない
- 知り合い (先輩など第三者も含む)
    に一から手伝われる・手伝うのは独走ではない
- 知り合いの質問に答えるのは、Q&A
    フォーラムと同じ範囲内で大丈夫
 しかし、Q&A フォーラムそのものを使った方がよい
- 締め切り後、プログラムを勉強のために交換するのは大丈夫
 
- 知り合いに USB メモリを貸すときには要注意
 
不正行為
  - 強力な調査ツールを使用
- 残念ながら毎年不正が発覚
- 倫理上、大学の目的と授業の約束事に対し、極めて許し難い行為
- 対応: 一問につき、一週間分の課題をすべて 0 点
- 必要に応じてさらに対応を強化
 
成績評価方法
授業中の演習課題とミニテスト、期末試験で総合的な評価
 
成功するには
  - 自覚
- 予習 (教科書を前もって読むなど)
- 睡眠 (睡眠不足でプログラミング効率が極端に低下)
- 環境 (机の整備など)
- 水分・糖分の補給 (部屋の外で!)
- 自動翻訳サイトの敬遠
 
Moodle
http://moo.sw.it.aoyama.ac.jp
(same as Discrete Mathematics I)
Enrollment key: (secret)
If you forgot your password, use "Forgotten your
username or password?" on the login page.
(caution: only enter either the username or the email address, not
both)
 
Minitest
  - Every week at the start of the lecture
- Every week, log in to your PC and got to Computer Practice I in Moodle
    before the lecture starts
- Every week, put your books, papers, wallets, phones,... into your bag,
    and your bag below your seat before the lecture starts
- At the end of the minitest, stay on the confirmation page, do not browse
    around
 
配布資料
  - 授業の予定
- 授業プリント
- 作業の要点 (1枚)
- 演習課題 01A3・01C1 の解答用紙 (1枚)
- 新版 C 言語プログラミングレッスン文法編「第8章
    式と演算子」(ホチキス止め)
 
Structure of Weekly Lectures
  - Minitest (ca. 10 minutes)
- Explanations (ca. 40 minutes)
- Exercises (extension past 18:20 possible) 
    
      - Repeatedly create a program, compile, test
- Upload the program to the Program Checking System
- Occasionally, fill in a handout and submit it to the responsible
        teacher
 
- Two times: Extended written test (~30 minute) instead of minites
- Last three times: Exercises only (i.e. no explanations)
- Term final exam
 
教科書
新版 C 言語プログラミングレッスン 入門編
結城 浩 著
ISBN 4-7973-3678-1 定価 本体 2,000 円 + 税
 
C Basic Data Types
  - 整数 (integer, int)、0 以上の整数 (unsigned
    int):1,3,234578,-345など
- 浮動小数点数 (floating point number, double):1.234,7E-13など
 
Attention: \ vs. ¥
  - "\" (backslash, reverse solidus) often appears as
    "¥" (yen sign) on Japanese systems
- This is a leftover from the era of 7bit/8bit character encodings
- In Unicode, these are separate
    characters: 
    
      - U+005C REVERSE SOLIDUS
- U+00A5 YEN SIGN
- (U+FFE5 FULLWIDTH YEN SIGN)
 
- Recommendation: 
    
      - Convert a syntactical "¥" to "\" in your
        mind
- For the Japanese currency, use 円, U+00A5, or full width ¥
 
 
演習の環境
  - エディタ (Notepad2、Notepad++、Meadow、Komodo
    Edit, 秀丸、xyzzy 等) 
    
      - 重要: 文字コードは常に UTF-8 (BOM 無し;
        メモ帳はダメ)
 
- ターミナル・エミュレータ (terminal emulator): Cygwin
  Terminal
- シェル (shell): Cygwin Bash Shell
- コンパイラ (compiler): gcc
- 問題文: Moodle、課題提出: Program Checking System
- 上記のものを常に開いたままの方が効率的
- 環境のデモ: C の簡単なプログラム
 
cygwin の使い方
便利な命令:
フォルダの作成: mkdir newfolder (例:
mkdir CP2014)
フォルダへの移動: cd CP2014
(フォルダ名とフォルダ名の間は \ のではなく
/)
Windows のフォルダへの移動 (C: ドライブの場合): cd
/cygdrive/c
現在のフォルダの場所の表示: pwd
現在のフォルダの内容の表示: ls (又は
dir)
 
A Simple C Program
(the most famous C program)
#include <stdio.h>
int main (void)
{
    printf ("Hello World!\n");
    return 0;
}
 
Program Compilation and Execution
  - Compilation: gcc 01A1.c
- Execution: ./a(or./a.exe)
To avoid overwriting a.exe:
  - Compilation: gcc -o 01A1 01A1.c
- Execution: ./01A1(or./01A1.exe)
 
Edit - Compile - Go
プログラミングは三つの作業の繰返し:
  - Edit: プログラムを書く、修正する
- Compile:
    人間の読めるプログラムから機械が実行できるプログラムへ
- Go: プログラムを実行してみる
コンパイラではなくてインタプリタ言語 (Ruby など)
を使うと 2. と 3. がまとめて実行
 
cygwin と gcc のインストール
(画像つ
き詳細)
  - セットアップツール (setup.exe or setup-x86_64.exe)
    をダウンロード
- 必ず次の Package をインストール 
    
      - diffutils
- gcc-core
- gcc-g++
- ruby (2年後期のデータ構造とアルゴリズム用)
- flex, bison, make
      (3年前期の言語理論とコンパイラ用)
- 必要に応じていつでも追加インストールや更新が可能
 
- Cygwin Terminal の設定: 
    
      - Text: Font: MSゴシック, 12-point など
- Text: Locale: C
- Text: Character set: UTF-8
 
 
質問の仕方
  - 演習問題をよく読む (例: This is not a real program.)
- 自分でしばらく (短すぎない、長すぎない) 考える
- Q&A
    フォーラムをチェック
- 質問を Q&A
    フォーラムに書き込む
 題名に注意:
 悪い例: 「エラー」、「アップロードについて」
 良い例: 「File starts with a BOM
    への対応」、 「01A1 の
    family name」
- 手をあげて質問
 
Program Checking System
 
ユーザ登録・授業登録
  - アカウント作成: sign up for a new
  account
- ユーザ ID は学生番号 (例: 15815789)
- 姓、名は学生証と同様 (例: 高崎・髙﨑など)
- メールアドレスは大学のウェブメール
  (a5815789@aoyama.jp)
- パスワードを忘れないように!!!
- Antispam Secret:
- 授業登録: 
    
  
 
Overall Program Checking System Error
If there is an overall error in the Program Checking System, a message such
as Ruby on Rails
application could not be started is displayed. Leave the screen as is,
and inform me immediately.

 
Partial Program Checking System Error
If there is a partial error in the Program Checking System, a message such
as We're
sorry, but something went wrong. Leave the screen as is, and
inform me immediately.

 
Server Error
If there is a server errror, a message such as Internal Server
Error is displayed. Leave the screen as is, and inform me
immediately.
  - Internal Server Error- The server encountered an internal error or misconfiguration and was
    unable to complete your request. - Please contact the server administrator, webmaster@sw.it.aoyama.ac.jp
    and inform them of the time the error occurred, and anything you might have
    done that may have caused the error. - More information about this error may be available in the server error
    log. 
 Apache/2.2.6 (Fedora) Server at rpcsr.sw.it.aoyama.ac.jp Port 80
 
Program Checking System 等がアクセス不可
  - まれに www/moo/rpcsr.sw.it.aoyama.ac.jp へアクセスが不可
- その場合の対応: 
    
  
 
Program Checking System の結果の表示
成功の例
Congratulations, you successfully
completed this assignment and received 100.0 points.
Attempt registered.
注: Indent 関係の表示は今週無視してください。
 
Program Checking System の結果の表示
失敗の例
Expected output and actual output
differ at line 3, see below. Submission rejected, please submit again. Actual
output line: 4 is not a prime number. Expected output line: 4 is not a prime
number. Problem occured in execution check number 1.
Attempt registered.
Expected output and actual output differ at line 3, see below.
Submission rejected, please submit again.
Actual output line:
4 is not a prime number.
Expected output line:
 4 is not a prime number.
Problem occured in execution check number 1.
 
Overview of Systems Used
  - Moodle
    (http://moo.sw.it.aoyama.ac.jp) 
    
      - Schedule
- Minitests
- Lecture notes
- Exercise problems
- Q&A Forum
 
- PC (N604b, other PC rooms, at home,...) 
    
      - Editor: Notepad2 or similar
- Compiler: gcc
- Execution: Cygwin Terminal
 
- Program Checking System
    (http://rpcsr.sw.it.aoyama.ac.jp) 
    
      - Uploading/checking of programs
 
 
演習問題の読み方
  - 青色 (例: Submit your
    program...; give the handout to
    your teacher):
 提出物、提出先 (Program Checking System はリンク付き)
- 灰色の背景 (例: 青山 例子):
    入力、出力、プログラムでそのままではない部分
- Reference (例: pp. 50-57):
    教科書など参考文献のページ番号など
- Hint: ヒント (豆知識もある)
 
Today's Exercises
注: 一題ごと完成して、提出 (提出が遅くなると減点)
最終的な締切は4月10日 (日曜日) 22:00
Q&A Forum の受け付け締め切りは問題の締切の一日前
  - 01A1: 普通のプログラムではない (コンパイル不用)
- 01A2: 自分独自の文書を使用
- 01A3: 型の範囲 (出力の予想と観察)
- 01C1: 回答を紙に書いて、担当の先生に今日提出
 
- 01B1: 数の合計
- 01B2: 一乗から十乗、浮動小数点数の表示
- 01C2: 「発展」問題: 成績の美化
 
次回への準備
  - 作ったプログラムを忘れずに保管 (USB, Z:
    ドライブなど)
 
- 帰るときにモニターの電源を必ず切る
    (真中のモニターも)
- 残った演習問題を宿題として完成、投稿
- 今日の復習
- 教科書の第三章 (pp. 48-74) を読む
- 文法編の第八章、式と演算子 (pp. 150-170、今日配布)
    を読む
- 自分のノートパソコンなどで環境を設定、テスト
- 環境設定に問題がある場合、来週必ずノートパソコンを持参
 
「計算機実習 I のための準備」の収集
演習に入る前に各列の担当の先生に返却
(名前、学生番号記入済み、完成した宿題のところ入り)
 
Glossary
  - data type
- データ型
- character encoding
- 文字コード
- syntactical
- 文法上の、構文上の
- full width
- 全角
- (to) compile
- コンパイル (する)
- compilation
- コンパイル (名詞)
- execution
- 実行