Microsoft Word - no14.docx

Size: px
Start display at page:

Download "Microsoft Word - no14.docx"

Transcription

1 ex26.c #define MAX 20 int max(int n, int x[]); int num[max]; int i, x; printf(" "); scanf("%d", &x); if(x > MAX) printf("%d %d \n", MAX, MAX); x = MAX; for(i = 0; i < x; i++) printf("%3d : ", i + 1); scanf("%d", &num[i]); printf("%d \n", max(x, num)); int max(int n, int x[]) int i, m = x[0]; for(i = 1; i < n; i++) if(m < x[i]) m = x[i]; return(m); str[][] num []

2 ex27.c int calc1(int x, int y); int calc2(int x[]); int num[2], n; num[0] = 10; num[1] = 10; n = calc1(num[0], num[1]); printf("num[0]=%2d, num[1]=%2d, n=%2d\n", num[0], num[1], n); n = calc2(num); printf("num[0]=%2d, num[1]=%2d, n=%2d\n", num[0], num[1], n); int calc1(int x, int y) x = x - 1; if(x > 0) y = y - 1; else y = y + 1; return(x + y); int calc2(int x[]) x[0] = x[0] - 1; if(x[0] > 0) x[1] = x[1] - 1; else x[1] = x[1] + 1; return(x[0] + x[1]); int int

3 ex28.c #define MAXLEN 80 int length(char str[]); int to_upper(char str[]); char string[maxlen + 1]; printf(": "); scanf("%80s", string); printf("%d \n", length(string)); to_upper(string); printf("%s \n", string); int length(char str[]) int i, len = 0; for(i = 0; str[i]!= '\0'; i++) len++; return(len); int to_upper(char str[]) int i, c = 0; for(i = 0; str[i]!= '\0'; i++) if((str[i] >= 'a') && (str[i] <= 'z')) str[i] -= 32; c++; return(c);

4 main array_sum_sqr array_average ex29.c #define MAX 20 array_sum_sqr( ); array_average( ); int num[max]; int i, x; printf(" "); scanf("%d", &x); if(x > MAX) printf("%d %d \n", MAX, MAX); x = MAX; for(i = 0; i < x; i++) printf("%3d : ", i + 1); scanf("%d", &num[i]); printf(" \n", array_sum_sqr( )); printf(" \n", array_average( ));

5 ex30.c /* */ /* */ double mulreal(double, double, double, double); double mulimage(double, double, double, double); void printcomplex(double, double); double areal, aimage; /* a */ double breal, bimage; /* b */ double creal, cimage; /* c */ printf("a : "); scanf("%lf", &areal); printf("a : "); scanf("%lf", &aimage); printf("b : "); scanf("%lf", &breal); printf("b : "); scanf("%lf", &bimage); creal = mulreal(areal, aimage, breal, bimage); /* */ cimage = mulimage(areal, aimage, breal, bimage); /* */ printcomplex(areal, aimage); printf(" * "); printcomplex(breal, bimage); printf(" = "); printcomplex(creal, cimage); printf("\n"); /* */ double mulreal(double xreal, double ximage, double yreal, double yimage) return xreal * yreal - ximage * yimage; /* */ double mulimage(double xreal, double ximage, double yreal, double yimage) return xreal * yimage + ximage * yreal; /* */ void printcomplex(double xreal, double ximage) printf("(%f%+fi)", xreal, ximage);

6 ex31.c /* */ /* */ struct complex double real; /* */ double image; /* */ ; /* */ struct complex mul(struct complex x, struct complex y); void printcomplex(struct complex x); struct complex a, b, c; /* a, b, c */ printf("a : "); scanf("%lf", &a.real); printf("a : "); scanf("%lf", &a.image); printf("b : "); scanf("%lf", &b.real); printf("b : "); scanf("%lf", &b.image); c = mul(a, b); /* */ printcomplex(a); printf(" * "); printcomplex(b); printf(" = "); printcomplex(c); printf("\n"); /* */ struct complex mul(struct complex x, struct complex y) struct complex z; z.real = x.real * y.real - x.image * y.image; z.image = x.real * y.image + x.image * y.real; return z; /* */ void printcomplex(struct complex x) printf("(%f%+fi)", x.real, x.image);

7 c = a 1 2 doible struct 1 1;... (); struct ;.. ex32.c /* */ /* */ struct ; /* */ ; /* */ ; /* */ mul( x, y); void print ( x); a, b, c; /* a, b, c */ printf("a : "); scanf("%d", &a. ); printf("a : "); scanf("%d", &a. ); printf("b : "); scanf("%d", &b. ); printf("b : "); scanf("%d", &b. );

8 c = mul(a, b); /* */ print (a); printf(" * "); print (b); printf(" = "); print (c); printf("\n");

Microsoft Word - no202.docx

Microsoft Word - no202.docx 1.4 ポインタと配列 ポインタ変数は前回説明したように 値の入っているアドレスを示す変数です では 配列はどの ようにメモリ上に格納されるか調べてみましょう ex07.c /* ポインタと配列の関係 */ int a[3]={1, 2, 3; /* int 型の大きさ 3 の配列として宣言 */ int *i; /* int 型へのポインタとして宣言 */ double x[3] = {1.0,

More information

Microsoft Word - no13.docx

Microsoft Word - no13.docx 4. 構造体 4.1 構造体とは たとえば 分数をそのまま扱うときを考えてみましょう 分数は分子と分母の 2 つの部分からな っていることから 2 つの変数を用いて表すことが必要です ここでは約分も行うこととします ex34.c /* 分数の計算 */ int gcd(int m, int n); int a_num, a_den; /* 分数 a */ int b_num, b_den; /* 分数

More information

Microsoft Word - no15.docx

Microsoft Word - no15.docx ex33.c /* */ #define IDLENGTH 7 /* */ #define MAX 100 /* */ /* */ struct student char idnumber[idlength + 1]; /* */ int math; /* () */ int english; /* () */ int japanese; /* () */ double average; /* */

More information

Microsoft Word - no12.doc

Microsoft Word - no12.doc 7.5 ポインタと構造体 構造体もメモリのどこかに値が格納されているのですから 構造体へのポインタ も存在します また ポインタも変数ですから 構造体のメンバに含めることができます まずは 構造体へのポインタをあつかってみます ex53.c /* 成績表 */ #define IDLENGTH 7 /* 学籍番号の長さ */ #define MAX 100 /* 最大人数 */ /* 成績管理用の構造体の定義

More information

main

main 14 1. 12 5 main 1.23 3 1.230000 3 1.860867 1 2. 1988 1925 1911 1867 void JPcalendar(int x) 1987 1 64 1 1 1 while(1) Ctrl C void JPcalendar(int x){ if (x > 1988) printf(" %d %d \n", x, x-1988); else if(x

More information

Microsoft Word - no15.docx

Microsoft Word - no15.docx 7. ファイルいままでは プログラムを実行したとき その結果を画面で確認していました 簡単なものならそれでもいいのですか 複雑な結果は画面で見るだけでなく ファイルに保存できればよいでしょう ここでは このファイルについて説明します 使う関数のプロトタイプは次のとおりです FILE *fopen(const char *filename, const char *mode); ファイルを読み書きできるようにする

More information

PowerPoint Presentation

PowerPoint Presentation p.130 p.198 p.208 2 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i i < NUM; i++ ) ) if if ( weight[i] > max ) max = weight[i]: if if ( weight[i] < min ) min = weight[i]: weight

More information

P05.ppt

P05.ppt 2 1 list0415.c forfor #include int i, j; for (i = 1; i

More information

Microsoft Word - no205.docx

Microsoft Word - no205.docx 3 応用 3.1 連結リスト 前回 先頭に追加する例を扱いました しかし start が指す node を変更することから 関数 の戻り値として作成しました 今回は ポインタ変数 start の値を関数で変更できるように ポイ ンタ変数へのポインタを利用します 先頭を削除するものと 最後を削除する関数を追加します ex25.c /* リストの追加と削除 */ typedef struct node

More information

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

[1] #include<stdio.h> main() { printf(hello, world.); return 0; } (G1) int long int float ± ± [1] #include printf("hello, world."); (G1) int -32768 32767 long int -2147483648 2147483647 float ±3.4 10 38 ±3.4 10 38 double ±1.7 10 308 ±1.7 10 308 char [2] #include int a, b, c, d,

More information

1 4 2 EP) (EP) (EP)

1 4 2 EP) (EP) (EP) 2003 2004 2 27 1 1 4 2 EP) 5 3 6 3.1.............................. 6 3.2.............................. 6 3.3 (EP)............... 7 4 8 4.1 (EP).................... 8 4.1.1.................... 18 5 (EP)

More information

Microsoft Word - no11.docx

Microsoft Word - no11.docx 3. 関数 3.1 関数関数は数学の関数と同じようなイメージを持つと良いでしょう 例えば三角関数の様に一つの実数値 ( 角度 ) から値を求めますし 対数関数の様に二つの値から一つの値を出すものもあるでしょう これをイメージしてもらえば結構です つまり 何らかの値を渡し それをもとに何かの作業や計算を行い その結果を返すのが関数です C 言語の関数も基本は同じです 0 cos 1 cos(0) =

More information

C言語によるアルゴリズムとデータ構造

C言語によるアルゴリズムとデータ構造 Algorithms and Data Structures in C 4 algorithm List - /* */ #include List - int main(void) { int a, b, c; int max; /* */ Ÿ 3Ÿ 2Ÿ 3 printf(""); printf(""); printf(""); scanf("%d", &a); scanf("%d",

More information

Microsoft Word - no103.docx

Microsoft Word - no103.docx 次は 数える例です ex19.c /* Zeller の公式によって 1 日の曜日の分布を求めるプログラム */ int year, month, c, y, m, wnumber, count[7] = {0, i; for(year = 2001; year

More information

P06.ppt

P06.ppt p.130 p.198 p.208 2 1 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i < NUM; i++ ) if ( weight[i] > max ) max = weight[i]: if ( weight[i] < min ) min = weight[i]: weight 3 maxof(a,

More information

P02.ppt

P02.ppt int If 2 1 ,,, 3 a + b ab a - b ab a * b ab a / b ab a % b ab a + b 4 2 list0201.c /, % /*/ int vx, vy; puts(""); printf("vx"); scanf("%d", &vx); printf("vy"); scanf("%d", &vy); printf("vx + vy = %d\n",

More information

新・明解C言語 ポインタ完全攻略

新・明解C言語 ポインタ完全攻略 2 1-1 1-1 /* 1-1 */ 1 int n = 100; int *p = &n; printf(" n %d\n", n); /* n int */ printf("*&n %d\n", *&n); /* *&n int */ printf(" p %p\n", p); /* p int * */ printf("&*p %p\n", &*p); /* &*p int * */ printf("sizeof(n)

More information

新・明解C言語で学ぶアルゴリズムとデータ構造

新・明解C言語で学ぶアルゴリズムとデータ構造 第 1 章 基本的 1 n 141 1-1 三値 最大値 algorithm List 1-1 a, b, c max /* */ #include int main(void) { int a, b, c; int max; /* */ List 1-1 printf("\n"); printf("a"); scanf("%d", &a); printf("b"); scanf("%d",

More information

プログラミング基礎

プログラミング基礎 C プログラミング Ⅱ 演習 2-1(a) BMI による判定 文字列, 身長 height(double 型 ), 体重 weight (double 型 ) をメンバとする構造体 Data を定義し, それぞれのメンバの値をキーボードから入力した後, BMI を計算するプログラムを作成しなさい BMI の計算は関数化すること ( ) [ ] [ ] [ ] BMI = 体重 kg 身長 m 身長

More information

新版明解C言語 実践編

新版明解C言語 実践編 2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,

More information

#define N1 N+1 double x[n1] =.5, 1., 2.; double hokan[n1] = 1.65, 2.72, 7.39 ; double xx[]=.2,.4,.6,.8,1.2,1.4,1.6,1.8; double lagrng(double xx); main

#define N1 N+1 double x[n1] =.5, 1., 2.; double hokan[n1] = 1.65, 2.72, 7.39 ; double xx[]=.2,.4,.6,.8,1.2,1.4,1.6,1.8; double lagrng(double xx); main =1= (.5, 1.65), (1., 2.72), (2., 7.39).2,.4,.6,.8, 1., 1.2, 1.4, 1.6 1 1: x.2 1.4128.4 1.5372.6 1.796533.8 2.198 1.2 3.384133 1.4 4.1832 1.6 5.1172 8 7 6 5 y 4 3 2 1.5 1 1.5 2 x 1: /* */ #include

More information

kiso2-09.key

kiso2-09.key 座席指定はありません 計算機基礎実習II 2018 のウェブページか 第9回 ら 以下の課題に自力で取り組んで下さい 計算機基礎実習II 第7回の復習課題(rev07) 第9回の基本課題(base09) 第8回試験の結果 中間試験に関するコメント コンパイルできない不完全なプログラムなど プログラミングに慣れていない あるいは複雑な問題は 要件 をバラして段階的にプログラムを作成する exam08-2.c

More information

Microsoft Word - no206.docx

Microsoft Word - no206.docx 3.2 双方向リスト 今までのリストは 前から順にたどることしかできませんでした 今度は逆にもたどることができる 双方向リストを扱います この場合は 構造体には次を表すポインタの他に前を表すポインタを持つ ことになります 今回は最初と最後をポインタを使うと取り扱いが面倒になるので 最初 (start) と最後 (end) を どちらとも構造体 ( 値は意味を持たない ) を使うことにします こうすることによって

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション 構造体 (struct) 構造体の宣言 typedef 宣言 配列では 複数のデータをひとまとまりにして操作することが出来る しかし それぞれのデータは同じ型 ( 例えば整数 あるいは浮動小数点数 ) 出なければならない 型の違うデータをひとまとまりにして扱う方法に 構造体がある 構造体 文文文文名前字 ( 文字列字字 ) 字 整数学籍番号 ( 整数 ) 身長 ( 浮動小数点数 ) 文字 配列 3

More information

C V C 6 1 6.1.............................. 1 6.......................... 3 6.3..................... 5 6.4 NULL............................. 8 6.5......................... 9 6.6..............................

More information

Microsoft PowerPoint - 説明3_if文switch文(C_guide3)【2015新教材対応確認済み】.pptx

Microsoft PowerPoint - 説明3_if文switch文(C_guide3)【2015新教材対応確認済み】.pptx 情報ネットワーク導入ユニット Ⅰ C 言語 if 文 switch 文 3 章 : プログラムの流れの分岐 if 文 if( 条件 ) 条件が成立すれば実行 if( 条件 ) ~ else 場合分け ( 成立, 不成立 ) if( 条件 A) ~ else if( 条件 B) ~ else if( 条件 C) ~ else 場合分け ( 複数の条件での場合分け ) 等価演算子 : == ( 等しい

More information

新・明解C言語 実践編

新・明解C言語 実践編 第 1 章 見 21 1-1 見えないエラー 見 List 1-1 "max2x1.h" a, b max2 List 1-1 chap01/max2x1.h max2 "max2x1.h" #define max2(a, b) ((a) > (b)? (a) : (b)) max2 List 1-2 List 1-2 chap01/max2x1test.c max2 #include

More information

Microsoft PowerPoint - program.ppt [互換モード]

Microsoft PowerPoint - program.ppt [互換モード] プログラミング演習 バージョン 1 担当教員 : 綴木馴 プログラムの決まりについて学ぶ おすすめする参考書 ザ C 戸川隼人サイエンス社 本日の予定 1. 授業の説明. 2. コンパイラーのインストール. プログラムの決まりについて学ぶ,P31 /* The most in C */ /* hello.c */ printf("hello,world n"); プログラムの決まり ( コメント )

More information

新版明解C言語入門編

新版明解C言語入門編 175cm 60kg ( ) 175cm 175.3cm 175.869758 cm 175cm 60kg p.177 18-1 vx - vy vx vy List -1 List -1 int vx, vy; puts(""); printf(" vx "); scanf("%d", &vx); printf(" vy "); scanf("%d", &vy); printf("vx + vy

More information

17 1. strucr Potter ( ) Harry Potter and the Philosopher s Stone 1997 English Title : Harry Potter and the Philosopher s Stone : : 1997 #include<stdio

17 1. strucr Potter ( ) Harry Potter and the Philosopher s Stone 1997 English Title : Harry Potter and the Philosopher s Stone : : 1997 #include<stdio 17 1. strucr Potter ( ) Harry Potter and the Philosopher s Stone 1997 English Title : Harry Potter and the Philosopher s Stone : : 1997 #include typedef struct Potter{ Potter; int main(void){

More information

解きながら学ぶC言語

解きながら学ぶC言語 printf 2-5 37 52 537 52 printf("%d\n", 5 + 37); 5370 source program source file.c ex00.c 0 comment %d d 0 decimal -2 -p.6 3-2 5 37 5 37-22 537 537-22 printf("537%d\n", 5-37); function function call ( )argument,

More information

r08.dvi

r08.dvi 19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev

More information

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2  2 B R b I 4 003 4 30 1 ASCII ( ) 0 17 0 NUL 16 DLE SP 0 @ P 3 48 64 80 96 11 p 1 SOH 17 DC1! 1 A Q a 33 49 65 81 97 113 q STX 18 DC " B R b 34 50 66 8 98 114 r 3 ETX 19 DC3 # 3 C S c 35 51 67 83 99 115 s 4 EOT

More information

Microsoft PowerPoint - 説明2_演算と型(C_guide2)【2015新教材対応確認済み】.pptx

Microsoft PowerPoint - 説明2_演算と型(C_guide2)【2015新教材対応確認済み】.pptx 情報ネットワーク導入ユニット Ⅰ C 言語 演算と型 演算 代入 演算と型 +,-,*,/,% = C 言語では 代入 の意味 vx = a + b; //a+b の結果を vx に代入 型 : int 型 ( 整数 ) double 型 ( 実数 ) 演算での型変換 ( 整数, 実数の混在 ) キャスト演算子 型を一時的に変更 書式指定 :printf("%6d n", a); 加減, 剰余演算

More information

ohp08.dvi

ohp08.dvi 19 8 ( ) 2019.4.20 1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: 2 (2) NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( 2) 3 (3) head cur tail head cur prev data

More information

ex14.dvi

ex14.dvi 1,, 0, b (b b 2 b ) n k n = n j b j, (0 n j b 1), n =(n k n k 1...n 1 n 0 ) b, n j j j +1, 0,...,b 1 (digit). b b, n b 1 ñ, ñ = k (b 1 n j )b j b N, n b n, n = b N n, n =ñ+1 b N, n m n + m (mod b N ),

More information

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >= II 14 2018 7 26 : : proen@mm.ics.saitama-u.ac.jp 14,, 8 2 12:00 1 O(1) n O(n) O(log n) O(1) 32 : 1G int 4 250 M 2.5 int 21 2 0 100 0 100 #include #define HASHSIZE 100 /* */ #define NOTFOUND 0

More information

Microsoft Word - Cプログラミング演習(12)

Microsoft Word - Cプログラミング演習(12) 第 12 回 (7/9) 4. いくつかのトピック (5)main 関数の引数を利用したファイル処理 main 関数は, 起動する環境から引数を受け取ることができる 例えば 次に示すように,main 関数に引数を用いたプログラムを作成する 01 /* sample */ 02 /* main 関数の引数 */ 03 #include 04 05 main(int argc, char

More information

DVIOUT

DVIOUT 2009 年度情報科学 & 情報科学演習レポート 7 学生用 学籍番号 : 氏名 : 下記の注意事項を守り 次ページ以降の問いに答え レポートを完成させなさい 提出期限 : 2009 年 6 月 16 日 ( 火 ) 13:00 まで提出場所 : 理学部棟正面玄関内に設置のレポートボックス 注意事項 : (1) このページを印刷し 必要事項を記入の上 ( 学籍番号欄と氏名欄は 2 箇所あるので忘れずに記入すること

More information

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf(hello World\n); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o 18 C ( ) 1 1 1.1 hello world.c 5 printf("hello World\n"); 6 } [ ] [ ] #include % cc hello_world.c %./a.out Hello World [a.out ] % cc hello_world.c -o hello_world [ ( ) ] (K&R 4.1.1) #include

More information

初歩のC言語ターミナル_2014_May.pages

初歩のC言語ターミナル_2014_May.pages C Mac OS X ( Vi Mi) Xcode CD >cd C:\Users\\Desktop gcc first.c C:\Users\\Desktop>gcc -o first first.c gcc first.c C:\Users\\Desktop>first Windows OS VisualStudio VisualStudio VS2012 CD C:\ >cd C:\Users\

More information

Microsoft PowerPoint - 12.ppt [互換モード]

Microsoft PowerPoint - 12.ppt [互換モード] 第 12 回構造体 1 今回の目標 構造体を理解する 構造体の定義の仕方を理解する 構造体型を理解する 構造体型の変数 引数 戻り値を理解する 複素数同士を足し算する関数を作成し その関数を利用するプログラムを作成する 2 複素数の足し算 複素数は実部と虚部の2つの実数で 表現される 表現される z = a+ bi 2 つの複素数 z 1 = a 1+ bi 1 と z2 = a2 + b2i の和

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

& & a a * * ptr p int a ; int *a ; int a ; int a int *a

& & a a * * ptr p int a ; int *a ; int a ; int a int *a int a = 123; a 123 :100 a 123 int *ptr = & a; a ptr ptr a 100 a 123 200 *ptr 200 a & & a a * * ptr p --------------------------------------------------------------------------------------------- int a

More information

演習課題No12

演習課題No12 演習課題 No.12 ( 課題は 3 題ある ) 課題 12-1 時間内提出 従来の C 言語には複素数を直接扱うデータ型はないので (*), 構造体で複素数 ( 英語で complex) を表すことにする. 複素数を表す構造体を以下のように定義する. struct complex float r; // 実部 ( 英語で real) float i; // 虚部 ( 英語で imaginary)

More information

Taro-最大値探索法の開発(公開版

Taro-最大値探索法の開発(公開版 最大値探索法の開発 0. 目次 1. 開発過程 1 目標 1 : 4 個のデータの最大値を求める 目標 2 : 4 個のデータの最大値を求める 改良 : 多数のデータに対応するため 配列を使う 目標 3 : n 個のデータの最大値を求める 改良 : コードを簡潔に記述するため for 文を使う 目標 4 : n 個のデータの最大値を求める 改良 : プログラムをわかりやすくするため 関数を使う 目標

More information

PowerPoint Presentation

PowerPoint Presentation ファイルの入出力 芝浦工業大学情報工学科 青木義満 今回の講義内容 ファイル入出力 ファイルからのデータ読込み ファイルと配列 2 1 ファイルへのデータ書き込み ( 復習 ) ソースファイル名 :fileio1.c データをファイルに書き込み #include int main(void) { ファイルポインタ宣言 int student_id = 100; char name[

More information

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C 1 6 9 1 main main 1 NULL NULL 1 15 23 25 48 26 30 32 36 38 43 45 47 50 52 for 2 (a) 2 2 1 Yacc 2 (b) 2 3 yytext tmp2 ("") tmp2->next->word tmp2 yytext tmp2->next->word

More information

演算増幅器

演算増幅器 構造体 ここまでに char int doulbe などの基本的なデータ型に加えて 同じデータ型が連続している 配列についてのデータ構造について習った これ以外にも もっと複雑なデータ型をユーザが定義 することが可能である それが構造体と呼ばれるもので 異なる型のデータをひとかたまりのデー タとして扱うことができる 異なるデータをまとめて扱いたい時とはどんな場合だろうか 例えば 住民データを管理したい

More information

‚æ4›ñ

‚æ4›ñ ( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9

More information

C B

C B C 095707B 2010 6 8 1 LEVE1 2 1.1 LEVEL 1.1................................................ 2 1.1.1 1................................................ 2 1.1.2 1.2..............................................

More information

1.ppt

1.ppt /* * Program name: hello.c */ #include int main() { printf( hello, world\n ); return 0; /* * Program name: Hello.java */ import java.io.*; class Hello { public static void main(string[] arg)

More information

02: 変数と標準入出力

02: 変数と標準入出力 C プログラミング入門 基幹 2 ( 月 4) 09: ポインタ 文字列 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/ teachers/w483692/cpr1/ 2014-06-09 1 関数できなかったこと 配列を引数として渡す, 戻り値として返す 文字列を扱う 呼び出し元の変数を直接書き換える 例 : 2 つの変数の値を入れ替える関数

More information

C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf ("sum=%d n",sum); 2

C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf (sum=%d n,sum); 2 アセンブラ (Z80) の例 ORG 100H LD B,10 SUB A LOOP: ADD A,B DEC B JR NZ,LOOP LD (SUM),A HALT ORG 200H SUM: DEFS 1 END 1 C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i

More information

02: 変数と標準入出力

02: 変数と標準入出力 C プログラミング入門 基幹 7 ( 水 5) 09: ポインタ 文字列 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/ teachers/w483692/cpr1/ 2016-06-08 1 関数できなかったこと 配列を引数として渡す, 戻り値として返す 文字列を扱う 呼び出し元の変数を直接書き換える 例 : 2 つの変数の値を入れ替える関数

More information

XMPによる並列化実装2

XMPによる並列化実装2 2 3 C Fortran Exercise 1 Exercise 2 Serial init.c init.f90 XMP xmp_init.c xmp_init.f90 Serial laplace.c laplace.f90 XMP xmp_laplace.c xmp_laplace.f90 #include int a[10]; program init integer

More information

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double

More information

Microsoft PowerPoint - 14Chap17.ppt

Microsoft PowerPoint - 14Chap17.ppt 17.1 do-while 文 p.161 例 17.1.1 p.22 例 5.1.1 第 17 章その他の制御文 17.1 do-while 文 17.2 goto 文とラベル 17.3 break 文による繰返し制御 17.4 continue 文による繰返し制御 /* ex17_1_1.c */ do while (i < 10); 条件を満たさなくても 1 回は実行 i = 10; とすると違いがわかる

More information

C言語講座 後半

C言語講座 後半 これまではあまり気にしてきませんでしたが それぞれ変数の型が持つ特性を気にかけていないと困る場合があります 例えば double 型と int 型を混ぜて使う場合を考えてみましょう int a; double b; a = 5; b = a/2.0; printf("b : %lf",b); int 型の a に整数 5 を代入し double 型の b には それを 2 で割った 2.5 を代入したいとします

More information

Microsoft Word - no204.docx

Microsoft Word - no204.docx 2. ファイル処理 2.1 ファイル処理の基本いままでは プログラムを実行したとき 入力はキーボードから入れていました また その結果を画面で確認していました 簡単なものならそれでもいいのですが 複雑な入力はファイルから読み込んだり 結果は画面で見るだけでなくファイルに保存できればよいでしょう ここでは ファイル処理について説明します 使う関数のプロトタイプは次のとおりです FILE *fopen(const

More information

kiso2-06.key

kiso2-06.key 座席指定があります Linux を起動して下さい 第6回 計算機基礎実習II 計算機基礎実習II 2018 のウェブページか ら 以下の課題に自力で取り組んで下さい 第5回の復習課題(rev05) 第6回の基本課題(base06) 第5回課題の回答例 ex05-2.c 1. キーボードから整数値 a を入力すると a*a*a の値を出力することを繰り返すプログラムを作成しなさい 2. ただし 入力された

More information

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó  ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡ (2018) 2018 5 17 0 0 if switch if if ( ) if ( 0) if ( ) if ( 0) if ( ) (0) if ( 0) if ( ) (0) ( ) ; if else if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 (0) 2 if else

More information

I void* School of Information Science, Japan Advanced Institute of Science and Technology

I void* School of Information Science, Japan Advanced Institute of Science and Technology I117 25 void* School of Information Science, Japan Advanced Institute of Science and Technology sdict ( ) idict ; long long double void* Japan Advanced Institute of Science and Technology 2008 1-2 1 idict

More information

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout <<

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout << C++ C C++ 1 C++ C++ C C++ C C++? C C++ C *.c *.cpp C cpp VC C++ 2 C++ C++ C++ [1], C++,,1999 [2],,,2001 [3], ( )( ),,2001 [4] B.W. /D.M.,, C,,1989 C Web [5], http://kumei.ne.jp/c_lang/ 3 Hello World Hello

More information

Microsoft Word - Cプログラミング演習(7)

Microsoft Word - Cプログラミング演習(7) 第 7 回 (6/4) 2. 構造体 構造体とは, 同じ型に限定されない複数の関連するデータメンバの集合である 構造体の宣言構造体指定子 struct を用いて struct 構造体タグ名 { メンバ 1 の宣言 ; メンバ 2 の宣言 ; メンバ n の宣言 ; }; 注 ) 構造体タグ名は構造体の型名で, 内容を定義するものでオブジェクトではなく, 論理的なテンプレートである 構造体の変数の宣言実際の記憶領域を占める物理的実体を確保する

More information

ex12.dvi

ex12.dvi 1 0. C, char., char, 0,. C, ("),., char str[]="abc" ; str abc.,, str 4. str 3. char str[10]="abc" ;, str 10, str 3., char s[]="abc", t[10] ;, t = s. ASCII, 0x00 0x7F, char., "abc" 3, 1. 1 8 256, 2., 2

More information

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B A/B (2010/10/08) Ver. 1.0 kurino@math.cst.nihon-u.ac.jp http://edu-gw2.math.cst.nihon-u.ac.jp/ kurino/2010/soft/soft.html 2010 10 8 A/B 1 2010 10 8 2 1 1 1.1 OHP.................................... 1 1.2.......................................

More information

1.1 1 C IIA $ cd comp3a %endminipage ~/comp3a mkdir $ mkdir comp3a $ cd comp3a C.c Emacs Cntrol x Control s 2 Emacs Control-x Control-f Control-

1.1 1 C IIA $ cd comp3a %endminipage ~/comp3a mkdir $ mkdir comp3a $ cd comp3a C.c Emacs Cntrol x Control s 2 Emacs Control-x Control-f Control- 1 C IIA 1 C IIA IIA 1.1 Mac OS X 1.1.1 Mac OS X Unicode(UTF-8) UTF-8 Jedit X( ) Emacs( ) Emacs Emacs Emacs [Finder] [] Emacs dock Jedit X C 1. Jedit X Dock drag & drop Jedit X [Finder] [] Jedit X Folder

More information

関数 C 言語は関数の言語 関数とは 関数の定義 : f(x) = x * x ; 使うときは : y = f(x) 戻り値 引数

関数 C 言語は関数の言語 関数とは 関数の定義 : f(x) = x * x ; 使うときは : y = f(x) 戻り値 引数 関数 C 言語は関数の言語 関数とは 関数の定義 : f(x) = x * x ; 使うときは : y = f(x) 戻り値 引数 関数の定義 戻り値の型 関数名 引数の型 引数の名前 int funcname ( int a, char b) { int c ; c = a * b ; return c ; 引数の型 引数の名前 戻り値 戻り値の型は int 変数 c の型も int return

More information

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ } C 2: A Pedestrian Approach to the C Programming Language 2 2-1 2.1........................... 2-1 2.1.1.............................. 2-1 2.1.2......... 2-4 2.1.3..................................... 2-6

More information

‚æ2›ñ C„¾„ê‡Ìš|

‚æ2›ñ C„¾„ê‡Ìš| I 8 10 10 I ( 6 ) 10 10 1 / 23 1 C ( ) getchar(), gets(), scanf() ( ) putchar(), puts(), printf() 1 getchar(), putchar() 1 I ( 6 ) 10 10 2 / 23 1 (getchar 1 1) 1 #include 2 void main(void){ 3 int

More information

超初心者用

超初心者用 3 1999 10 13 1. 2. hello.c printf( Hello, world! n ); cc hello.c a.out./a.out Hello, world printf( Hello, world! n ); 2 Hello, world printf n printf 3. ( ) int num; num = 100; num 100 100 num int num num

More information

[Problem F] 古い記憶 良さそうな方法は思いつかなかった アイディア募集中!!! かなり強引に解いている 各判定データに対して 30 秒程度かかる 元の文章と改ざん文章の関係を考える ウィルス感染の可能性は高々 2 回であり 各々の感染では 1 文字削除 1 文字追加 1 文字変更が行われ

[Problem F] 古い記憶 良さそうな方法は思いつかなかった アイディア募集中!!! かなり強引に解いている 各判定データに対して 30 秒程度かかる 元の文章と改ざん文章の関係を考える ウィルス感染の可能性は高々 2 回であり 各々の感染では 1 文字削除 1 文字追加 1 文字変更が行われ [Problem F] 古い記憶 良さそうな方法は思いつかなかった アイディア募集中!!! かなり強引に解いている 各判定データに対して 30 秒程度かかる 元の文章と改ざん文章の関係を考える ウィルス感染の可能性は高々 2 回であり 各々の感染では 1 文字削除 1 文字追加 1 文字変更が行われる 削除と追加は双対な関係であるので 改ざん文章に対して 改ざん文章そのもの ( 実際にはウィルス感染が起こっていなかった

More information

printf("5つの整数を入力して下さい \n"); /* データ入力 */ for( /*** 02 ***/ ){ printf("%dつ目の入力 :",i+1); scanf("%d", /*** 03 ***/ ); sum=dat[0]; /* 合計値の初期設定 */ n_max= 0

printf(5つの整数を入力して下さい \n); /* データ入力 */ for( /*** 02 ***/ ){ printf(%dつ目の入力 :,i+1); scanf(%d, /*** 03 ***/ ); sum=dat[0]; /* 合計値の初期設定 */ n_max= 0 電子情報競技会ソフトウェア課題 1 Question_1 プロジェクト内のソースプログラムの /*** XX ***/ に適当な語句 式等を入れ プログラムを完成させなさい ここで 同じ番号の /*** XX ***/ には同じ語句 式等が入る /*** XX ***/ の部分以外は書き換えてはならないが 別のソースファイルにてテストしてもかまわない [ プログラムの説明 ] 1. 処理内容 2 桁の整数データ

More information

char int float double の変数型はそれぞれ 文字あるいは小さな整数 整数 実数 より精度の高い ( 数値のより大きい より小さい ) 実数 を扱う時に用いる 備考 : 基本型の説明に示した 浮動小数点 とは数値を指数表現で表す方法である 例えば は指数表現で 3 書く

char int float double の変数型はそれぞれ 文字あるいは小さな整数 整数 実数 より精度の高い ( 数値のより大きい より小さい ) 実数 を扱う時に用いる 備考 : 基本型の説明に示した 浮動小数点 とは数値を指数表現で表す方法である 例えば は指数表現で 3 書く 変数 入出力 演算子ここまでに C 言語プログラミングの様子を知ってもらうため printf 文 変数 scanf 文 if 文を使った簡単なプログラムを紹介した 今回は変数の詳細について習い それに併せて使い方が増える入出力処理の方法を習う また 演算子についての復習と供に新しい演算子を紹介する 変数の宣言プログラムでデータを取り扱う場合には対象となるデータを保存する必要がでてくる このデータを保存する場所のことを

More information

<4D F736F F D20438CBE8CEA8D758DC03389F0939A82C282AB2E646F63>

<4D F736F F D20438CBE8CEA8D758DC03389F0939A82C282AB2E646F63> C 言語講座第 3 回 キャスト ( 型変換 ) 強制的に式の型を変換する ( 変換したい型名 ) 変換元で記述する int num_a = 10, num_b = 3; float result1, result2; // 結果格納用 // 計算用 result1 = num_a / num_b; // 通常のint/int 割り算 result2 = (float)num_a / num_b;//

More information

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル Instruction Manual Disk No. RE01 6th Edition: November 1999 (YK) All Rights Reserved, Copyright 1996 Yokogawa Electric Corporation 801234567 9 ABCDEF 1 2 3 4 1 2 3 4 1 2 3 4 1 2

More information

Microsoft PowerPoint - class04.ppt

Microsoft PowerPoint - class04.ppt フローチャート フローチャートとは プログラムの処理の流れを整理し 図的に順序立てて描いたもの 流れ図流れ図ともいう 例 : 始め 半径 R 端子 : 開始 終了 停止などを示す 手操作入力 : キーボードなどから手で操作して入力することを示す 面積 S πr 2 処理 : あらゆる種類の処理を示す S 終わり 表示 : ディスプレイ表示を示す このようにフローチャートでは 記号形状自体が処理の意味を示している

More information

プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; } Point; 問題 18. 問題 17 の

プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; } Point; 問題 18. 問題 17 の プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; Point; 問題 18. 問題 17 の Point を用いて 2 点の座標を入力するとその 2 点間の距 離を表示するプログラムを作成せよ 平方根は

More information

2 P.S.P.T. P.S.P.T. wiki 26

2 P.S.P.T. P.S.P.T. wiki  26 P.S.P.T. C 2011 4 10 2 P.S.P.T. P.S.P.T. wiki p.s.p.t.since1982@gmail.com http://www23.atwiki.jp/pspt 26 3 2 1 C 8 1.1 C................................................ 8 1.1.1...........................................

More information

untitled

untitled II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}

More information

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* ( 2016 2016 07 28 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF : 11011 N N 0 N N 11 1001 N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) 1100100 (2) 1111011 (3) 1110010 (4) 1001011

More information

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç C (3) if else switch AND && OR (NOT)! 1 BMI BMI BMI = 10 4 [kg]) ( [cm]) 2 bmi1.c Input your height[cm]: 173.2 Enter Input your weight[kg]: 60.3 Enter Your BMI is 20.1. 10 4 = 10000.0 1 BMI BMI BMI = 10

More information

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó  ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡ (2018) 2018 5 24 ( ) while ( ) do while ( ); for ( ; ; ) while int i = 0; while (i < 100) { printf("i = %3d\n", i); i++; while int i = 0; i while (i < 100) { printf("i = %3d\n", i); i++; while int i =

More information

ファイル入出力

ファイル入出力 C プログラミング Ⅱ の基礎 とは ファイルへデータを書き込んだり ( 出力 ), ファイルからデータを読み込んだり ( 入力 ) する C 言語では キーボードからの入力 画面への出力と同じようなコードで 処理を実現できる プログラム 入力 出力 ファイル 出力 入力 2 入出力の基本 ストリーム プログラム上で様々な装置への入出力を行う機構様々な入出力装置を統一的な方法で扱うことができる ハードディスクなどではファイルデータによって入出力が行われる

More information

C 言語第 3 回 2 a と b? 関係演算子 a と b の関係 関係演算子 等しい a==b 等しくない a!=b より大きい a>b 以上 a>=b より小さい a<b 以下 a<=b 状態 真偽 値 条件が満たされた場合 TRUE( 真 ) 1(0 以外 ) 条件が満たされなかった場合 F

C 言語第 3 回 2 a と b? 関係演算子 a と b の関係 関係演算子 等しい a==b 等しくない a!=b より大きい a>b 以上 a>=b より小さい a<b 以下 a<=b 状態 真偽 値 条件が満たされた場合 TRUE( 真 ) 1(0 以外 ) 条件が満たされなかった場合 F C 言語第 3 回 三つの基本構造 ( シラバス 5 6 回目 ) 1 1 順次処理上から順番に実行していく #include int main(void) { long x, y; 最初 長い整数がつかえる 負の数もか だいたい ±21 億まで OK なんだ 掛け算するぞ x = 1000*2000; scanf("%ld", &y); printf("%ld", x*y);

More information

gengo1-11

gengo1-11 関数の再帰定義 自然数 n の階乗 n! を計算する関数を定義してみる 引数は整数 返却値も整数 n! = 1*2*3*... * (n 1)*n である ただし 0! = 1 とする int factorial(int n) int i, tmp=1; if( n>0 ) for(i=1; i

More information

:30 12:00 I. I VI II. III. IV. a d V. VI

:30 12:00 I. I VI II. III. IV. a d V. VI 2017 2017 08 03 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF X [ S ] a S S ; X X X, S [, a, ], ; BNF X (parse tree) (1) [a;a] (2) [[a]] (3) [a;[a]] (4) [[a];a] : [a] X 2 222222

More information

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B A/B (2018/06/08) Ver. 1.0 kurino@math.cst.nihon-u.ac.jp http://edu-gw2.math.cst.nihon-u.ac.jp/ kurino/2018/soft/soft.html 2018 6 8 A/B 1 2018 6 8 2 1 1 1.1 OHP.................................... 1 1.2

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション プログラミング初級 第 7 回 2017 年 5 月 29 日 配列 ( 復習 )~ 文字列 1 配列とは 2 配列 : 複数の変数をグループとしてまとめて扱うもの 配列 変数 int data[10]; 整数型の配列 同種のデータ型を連続して確保したものを配列とよぶ = 整数がそれぞれにひとつずつ入る箱を 10 個用意したようなもの int data; 整数型の変数 = 整数がひとつ入る dataという名前の箱を用意したようなもの

More information

/

/ / 1 UNIX AWK( ) 1.1 AWK AWK AWK A.V.Aho P.J.Weinberger B.W.Kernighan 3 UNIX AWK GNU AWK 1 1.2 1 mkdir ~/data data ( ) cd data 1 98 MS DOS FD 1 2 AWK 2.1 AWK 1 2 1 byte.data 1 byte.data 900 0 750 11 810

More information

Microsoft Word - 05

Microsoft Word - 05 平成 24 年度講義 担当 : 富井尚志 (tommy@ynu.ac.jp) 第 5 回 配列を扱うアルゴリズム (2) 前回第 4 回 配列を扱うアルゴリズム (1) の復習 第 4 回 配列を扱うアルゴリズム (1) 配列 ( 再出 ) 配列って?, 宣言の方法, 計算機内部の記憶と配列の関係, 多次元配列, 配列の初期化, 文字列 配列を用いたプログラム例 線形探索 探索, 線形探索, 通常のプログラム

More information

C言語7

C言語7 C 言語 7 ポインタ アドレスを出力 int a; a=5; printf(" 変数 aの値は %dです n", a); printf(" 変数 aのアドレスは %pです n", &a); 実行結果 変数 a の値は 5 です 変数 a のアドレスは 0038FAC4 です 変数 a の値は 15 です 変数 a のアドレスは 0038FAC4 です 注 アドレスの値は実行環境やプログラムの実行状況により異なります

More information

1 ( )

1 ( ) I : :155727B : :2015 7 30 1 ( ) 2 2 18 2.1............................................ 18 2.1.1....................................... 18 2.1.2...................................... 19 2.1.3...................................

More information

Microsoft PowerPoint - 12.ppt [互換モード]

Microsoft PowerPoint - 12.ppt [互換モード] 第 12 回新しい型と構造体 1 今回の目標 新しい型の定義法を理解する 構造体を理解する 複素数同士を足し算する関数を作成し その関数を利用するプログラムを作成する 2 複素数の足し算 複素数は実部と虚部の2つの実数で 表現される z = a+ bi z = a + bi z = a + b i 2 つの複素数 1 1 1 と 2 2 2 の和 z = a + bi は 次式で与えられる 3 3

More information

02: 変数と標準入出力

02: 変数と標準入出力 C プログラミング入門 基幹 7 ( 水 5) 09: ポインタ 文字列 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/teachers/w 483692/CPR/ 207-06-4 関数できなかったこと 2 配列を引数として渡す, 戻り値として返す 文字列を扱う 呼び出し元の変数を直接書き換える 例 : 2 つの変数の値を入れ替える関数

More information

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v 1 http://www7.bpe.es.osaka-u.ac.jp/~kota/classes/jse.html kota@fbs.osaka-u.ac.jp /* do-while */ #include #include int main(void) double val1, val2, arith_mean, geo_mean; printf( \n );

More information

実際の株価データを用いたオプション料の計算

実際の株価データを用いたオプション料の計算 2002 2 20 1 1 3 2 3 2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 2.1.1 : : : : : : : : : : : : : : : : : : : : 5 2.1.2 : : : : : : : : : : : : : : : : : : : : 6 2.2 : : : : : : : : : :

More information