1 / 19

高度プログラミング演習 (0 2 )

高度プログラミング演習 (0 2 ). テキスト / 連絡先. http://www.cse.ec.kyushu-u.ac.jp/~oka/code/ 印刷しないこと。 岡村耕二 & 大学院生 code@ec.kyushu-u.ac.jp. Microsoft Visual C++ での プログラム実行までの手順. step 1. step 2. step 3. step 4. ビルドと 実行. プロジェクト の新規作成. C++ソース ファイルの 新規作成. C++ソース ファイルの 編集. ソースファイルは複数からなることがある。

Télécharger la présentation

高度プログラミング演習 (0 2 )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 高度プログラミング演習(02)

  2. テキスト/連絡先 • http://www.cse.ec.kyushu-u.ac.jp/~oka/code/ • 印刷しないこと。 • 岡村耕二&大学院生 • code@ec.kyushu-u.ac.jp

  3. Microsoft Visual C++でのプログラム実行までの手順 step 1 step 2 step 3 step 4 ビルドと 実行 プロジェクト の新規作成 C++ソース ファイルの 新規作成 C++ソース ファイルの 編集 ソースファイルは複数からなることがある。 プロジェクトとは、それらの一連のソースファイルをまとめたもの。

  4. 今日覚えること • C言語プログラムの作成方法の基礎中の基礎 • 変数(メモリ)とは何か理解する。 • 画面に表示できるようになる。 • キーボードから入力できるようになる。

  5. ひながた・最小のCプログラム void main() { }

  6. 宣言・プログラム中に現れるものはそれがどういうものか宣言する必要がある。宣言・プログラム中に現れるものはそれがどういうものか宣言する必要がある。 void printf(); void main() { printf(); }

  7. ヘッダファイル・色々な宣言がまとめて書かれている。ヘッダファイル・色々な宣言がまとめて書かれている。 #include<stdio.h> void main() { printf(); }

  8. 変数と宣言 void main() { int a=0; /* 整数 */ int b=1; int c=0; c = a + b; } 変数、メモリみたいな もの、メモリそのもの。 一時的に情報を保存 する箱。

  9. 変数の値の表示 printf() #include <stdio.h> void main() { int a=1; int b=2; printf(“%d %d \n”,a,b); }

  10. printf()では、フォーマットが重要 #include <stdio.h> void main() { int a=1; char *s=“moji”; /* 文字列 */ printf(“ seisu %d \n”,a); printf(“ moji %s \n”,s); }

  11. printf()・改行を出力する。 #include <stdio.h> void main() { printf(“ Hello World \n”); printf(“ Hello \n”); printf(“ World\n”); printf(“ Hello ”); printf(“ World\n”); }

  12. キーボードから入力してみよう。 #include <stdio.h> void main() { int a=0; scanf(“%d”, &a); printf(“%d\n”,a); }

  13. キーボードから入力してみよう2 #include <stdio.h> void main() { int a=0; printf(“ Input : “); scanf(“%d”, &a); a = a + 10; printf(“Output : %d\n”,a); }

  14. キーボードから入力してみよう3 #include <stdio.h> void main() { int a=0,b=0; printf(“ Input : “); scanf(“%d %d”, &a,&b); a = a + 10; b = b +100; printf(“Output : %d %d\n”,a,b); } Scan() は printf() みたくフォーマットを覚える。

  15. 四則演算 #include <stdio.h> void main() { int a=4, b=2, c=0; c=a+b; printf(“Tashi-zan %d\n”,c); c=a-b; printf(“Hiki-zan %d\n”,c); c=a*b; printf(“Kake-zan %d\n”,c); c=a/b; printf(“Wari-zan %d\n”,c); }

  16. 四則演算(応用) #include <stdio.h> void main() { int a=4, b=2; a=a+b; printf(“Tashi-zan %d\n”,a); }

  17. 練習問題 • 2つの数字を入力してその和を表示するプログラムを作成せよ。

  18. 練習問題 •  台形の上底、下底、高さを入力してその面積を出力するプログラムを作成せよ。 • 5つの整数を入力して、その総和と平均値を出力するプログラムを作成せよ。 • 3けたの2進数を入力してそれを10進数で出力するプログラムを作成せよ。

  19. 演習問題 •  円の半径を入力してその円周、面積を出力するプログラムを作成せよ。円周率は 3 としてよい。 • 3けたの2進数を二つ入力してその和を  10進数で出力するプログラムを作成せよ。 講義システムを用いて提出すること。

More Related