P03.ppt

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

P02.ppt

P05.ppt

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

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

8 if switch for while do while 2

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

PowerPoint Presentation

‚æ4›ñ

新版明解C言語入門編

fuga scanf("%lf%*c",&fuga); 改行文字を読み捨てる 10 進数の整数 おまじない取り込んだ値を代入する変数 scanf( %d%*c,&hoge); キーボードから取り込め という命令 1: scanf 1 1: int double scanf %d %lf printf

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

main

4 分岐処理と繰返し処理 ( 教科書 P.32) プログラムの基本的処理は三つある. (1) 順次処理 : 上から下に順番に処理する ぶんきそろ (2) 分岐処理 : 条件が揃えば, 処理する はんぷく (3) 反復処理 : 条件が揃うまで処理を繰り返す 全てのプログラムは (1) から (3) の

P06.ppt

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

Microsoft PowerPoint - C言語の復習(配布用).ppt [互換モード]


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

<4D F736F F D20438CBE8CEA8D758DC F0939A82C282AB2E646F63>

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

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

プログラミング基礎

新版明解C言語 実践編

/* 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

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

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

明解Javaによるアルゴリズムとデータ構造

プログラミングA

プログラミング及び演習 第1回 講義概容・実行制御

untitled

プログラミングA

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

2004

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

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

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

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

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

kiso2-06.key

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

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

数値計算

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

超初心者用

Microsoft PowerPoint - lec10.ppt

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

K227 Java 2

Prog1_6th

I J

新・明解C言語 実践編

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.

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

Microsoft PowerPoint - lec4.ppt

Networking Semester 802.3

4-4 while 文 for 文と同様 ある処理を繰り返し実行するためのものだが for 文と違うのは while 文で指定するのは 継続条件のみであるということ for 文で書かれた左のプログラムを while 文で書き換えると右のようになる /* 読込んだ正の整数値までカウントアップ (for

tuat1.dvi

Java

gengo1-2

kiso2-09.key

cp-7. 配列

Java演習(4) -- 変数と型 --

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-

問 2 ( 型変換 ) 次のプログラムを実行しても正しい結果が得られない 何が間違いかを指摘し 正しく修正せよ ただし int サイズが 2 バイト long サイズが 4 バイトの処理系での演算を仮定する #include <stdio.h> int main( void ) { int a =

サービス付き高齢者向け住宅賠償責任保険.indd

プログラミング及び演習 第1回 講義概容・実行制御

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)* (

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

r03.dvi

untitled

橡07第1章1_H160203_.PDF

Java updated

次に示す数値の並びを昇順にソートするものとする このソートでは配列の末尾側から操作を行っていく まず 末尾の数値 9 と 8 に着目する 昇順にソートするので この値を交換すると以下の数値の並びになる 次に末尾側から 2 番目と 3 番目の 1

Microsoft Word - no15.docx

ohp03.dvi

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:

日本外傷歯学会認定医(平成24年11月30日付) H

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

Microsoft Word - C.....u.K...doc

ex14.dvi

tuat2.dvi

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

目次

コーディング基準.PDF

TEX American Mathematical Society PostScript Adobe Systems Incorporated

untitled

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

C言語7

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

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

プログラミング及び演習 第1回 講義概容・実行制御

Microsoft Word - no15.docx

For_Beginners_CAPL.indd

1. 入力した正の整数を降順に並べ換えて出力するプログラムを作成せよ プログラムは個別にコンパイルし make コマンドで実行すること 入力データは 50 以下とし 以下の数が混在しているとする 16 進数 : 先頭 1 文字が x または X( エックスの小文字か大文字 ) 8 進数 : 先頭 1

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 >=

Microsoft PowerPoint - C_Programming(3).pptx

3-4 switch 文 switch 文は 単一の式の値によって実行する内容を決める ( 変える ) 時に用いる 例えば if 文を使って次のようなプログラムを作ったとする /* 3 で割った余りを求める */ #include <stdio.h> main() { int a, b; } pri

C言語入門

Transcription:

(2) Switch case 5 1 1 2 1

list0317.c if /*/ intnum; printf(""); scanf("%d", &num); 2 if (num % 3 == 0) puts( 0"); else if (num % 3 == 1) puts(" 1"); else puts( 32"); 3 if list0318.c /*/ intnum; printf(""); scanf("%d", &num); switch ( num % 3 ) case 0 : puts( ); break ; case 1 : puts( 1); break ; case 2 : puts( 2); break ; 4 2

switch ( num % 3 ) 0 1 2 case 0 : puts( ); break ; case 1 : puts( 1); break ; case 2 : puts( 2); break ; Switch break switch case 5 list0319.c /*switch/ int sw; printf(""); scanf("%d", &sw); switch (sw) case 1 : puts("a"); puts("b"); break; case 2 : puts("c"); break; case 5 : puts("d"); break; case 6 : break; case 7 : puts("e"); break; default : puts("f"); break; default : switch 6 3

switch (sw) case 1 : puts("a"); puts("b"); break; case 2 : puts("c"); case 5 : puts("d"); break; case 6 : case 7 : puts("e"); break; default : puts("f"); break; sw 1, 2, 5, 6, 7 7 Switch if 8 4

C dowhile while for 9 1008 int a, b; a = 1; b = 8 * a; printf( %d\n, b ); a = 2; b = 8 * a; printf( %d\n, b ); a = 12; b = 8 * a; printf( %d\n, b ); 10 5

1008(for) int b, i ; for ( i=1; i <= 12; i++ ) b = 8 * i ; printf( %d\n, b ); for 11 A B C for ( i=1; i <= 12; i++ ) b = 8 * i ; printf( %d\n, b ); i : Ai1 B A C B B0 C 12 6

A B C for ( i=1; i <= 12; i++ ) i : b = 8 * i ; printf( %d\n, b ); Ai1 B A i C B i 12 C i++(i) 13 for ( int i ; for ( i=1; i <= 12; i++ ) printf( %d\n, i ); i += 2 i += 3 14 7

for ( int i ; for ( i=12; i >=1 ; i-- ) printf( %d\n, i ); 15 list0413.c (p.76) int i, no; printf( input number"); scanf("%d", &no); for (i = 1; i <= no; i++) putchar( * ); putchar('\n'); For if putchar ( * 16 8

for (i = 1; i <= no; i++) putchar( * ); 1 n n for (i = 0; i < no; i++) putchar( * ); 0 n-1 n 17 5 18 9

int cont; int no; do printf("input number : "); scanf( "%d", &no ); if( no % 5 ) puts("5"); else puts("5"); list0401.c (p.60) while(cont == 0); printf("continue? Yes=0, No=9 : "); scanf("%d", &cont); do while return(0); 19 do while () do printf("continue? Yes=0, No=9 : "); scanf("%d", &cont); cont while (cont == 0); cont 0 20 10

list0404.c do intno = 1; intsum = 0; do sum = sum + no; no = no + 1; while (no <= 5); printf( 1+2+3+4+5= %d\n", sum); return(0); 21 intno = 1; no 1 int no; no = 1; no no1 22 11

List 4-4 intno = 1; intsum = 0; no15 do sum = sum + no; no = no + 1; while (no <= 5); no 5 1 sum = 0 + 1; no = 1 + 1; sum=1, no=2 2 sum = 1 + 2; no = 2 + 1; sum=3, no=3 3 sum = 3+ 3; no = 3 + 1; sum=6, no=4 4 sum = 6 + 4; no = 4 + 1; sum=10, no=5 5 sum = 10+ 5; no = 5 + 1; sum=15, no=6 while (no <= 5); 23 sum = sum + no; sumnosum no = no + 1; sum += no; no += 1; sumno no1 -=, *=, /=, %= 24 12

sum = sum + no; sumnosum no = no + 1; sum += no; no += 1; sumno no1 -=, *=, /=, %= 25 no = no + 1; no += 1; no1 no = no 1; no++; no -= 1; no -- ; 26 13

int i ; for ( i=1; i <= 12; i++ ) printf( %d\n, i ); i+=2 i2 27 list0404 intno = 1; intsum = 0; do sum += no; no ++; while (no <= 5); printf( 1+2+3+4+5= %d\n", sum); return(0); 28 14

List4-6do-whilefor 5 inti; intsum = 0; for ( i=1; i <=5; i++) sum += i; printf( 1+2+3+4+5= %d\n", sum); return(0); 29 while () do, while 30 15

loop.c inti=0; 0 while ( 1 ) i++; printf( %d, i ); return(0); CTRLC 31 100 inti; i = 0; while ( ) i++; printf( %d\n, i ); printf( \n ); return(0); for 32 16

i = 0; while ( i < 100 ) i++; printf( %d\n, i ); for ( i=1; i <= 100; i++ ) printf( %d\n, i ); For 33 break.c int i ; for ( i=0; i < 10; i++ ) if( i == 5 ) break; printf( %d\n, i ); 34 17

continue.c int i ; for ( i=0; i < 10; i++ ) if( i == 5 ) continue; printf( %d\n, i ); i5 35 while dowhile for while break continue 36 18

Switch 112 2 28 4, 6, 9, 11 30 135781012 31 kadai3-1.c kadai3-2.c 3Kadai3-1 0 do while kadai3-3.c 37 0100 kada3-4.c 38 19

39 20