(1 ) scanf(

Similar documents
‚æ4›ñ

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

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

untitled

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

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

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

卒 業 研 究 報 告.PDF

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

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

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

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

tuat1.dvi

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

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

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

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

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

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

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

PowerPoint Presentation

新版明解C言語 実践編

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

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

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

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

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-

ohp03.dvi

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

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

ex12.dvi

P05.ppt

数値計算

r03.dvi

プログラミング基礎

C B

double float

解きながら学ぶC++入門編

ex14.dvi

Taro-プログラミングの基礎Ⅱ(公

+ +

1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return 0; 戻り値 1: main() 2.2 C main

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

r08.dvi

P03.ppt

prog-text.dvi

ohp08.dvi

新・明解C言語 実践編

C ( ) C ( ) C C C C C 1 Fortran Character*72 name Integer age Real income 3 1 C mandata mandata ( ) name age income mandata ( ) mandat

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

[ 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:

2008 IIA (program) pro(before)+gram(write) (artificial language) (programming languege) (programming) (machine language) (assembly language) ( )

Taro-ファイル処理(公開版).jtd


P02.ppt

8 / 0 1 i++ i 1 i-- i C !!! C 2

kiso2-06.key

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

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

Microsoft PowerPoint - 14Chap17.ppt

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

kiso2-09.key

gengo1-2

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

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

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

本サンプル問題の著作権は日本商工会議所に帰属します また 本サンプル問題の無断転載 無断営利利用を厳禁します 本サンプル問題の内容や解答等に関するお問 い合わせは 受け付けておりませんので ご了承ください 日商プログラミング検定 STANDARD(C 言語 ) サンプル問題 知識科目 第 1 問 (

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

スライド 1

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

USB ID TA DUET 24:00 DUET XXX -YY.c ( ) XXX -YY.txt() XXX ID 3 YY ID 5 () #define StudentID 231

Informatics 2010.key

1 4 2 EP) (EP) (EP)

/* 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 Word - no15.docx

1. 入力した文字列を得る 1.1. 関数 scanf() を使う まずは関数 scanf() を使ったプログラムを作ってみましょう 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: #include<stdio.h> #define SIZE 128 main(

Java

解きながら学ぶJava入門編

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D

Microsoft Word - Sample_CQS-Report_English_backslant.doc

橡Pro PDF

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

Informatics 2014

I J

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

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

r07.dvi

ohp07.dvi

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

(K&R 2.9) ~, &,, >>, << 2. (K&R 5.7) 3. (K&R 5.9) 4. (K&R 5.10) (argc argv atoi(), atof() ) 5. (K&R 7.5) (K&R 7.6) - FILE, stdin, stdout, std

joho07-1.ppt

Informatics 2015

HITACHI 液晶プロジェクター CP-AX3505J/CP-AW3005J 取扱説明書 -詳細版- 【技術情報編】

ex01.dvi

file:///D|/C言語の擬似クラス.txt

x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i )

取扱説明書 -詳細版- 液晶プロジェクター CP-AW3019WNJ

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

1.ppt

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

Transcription:

I 1 C 1 1.1.................................... 1 1.2.................................... 1 1.3.................................... 2 1.4............................ 2 1.4.1............................. 2 1.4.2.................................. 3 1.4.3.................................... 4 1.5......................................... 4 2 C 5 2.1 C................................. 5 2.2 printf I....................................... 7 3 I 9 3.1 CPad(bcpad)..................................... 9 3.2 I....................................... 11 4 13 4.1 ( )..................................... 13 4.2......................................... 13 4.3.......................................... 14 4.3.1.................................... 14 4.3.2................................ 14 4.3.3.......................... 15 4.3.4............................... 15 4.4 printf II....................................... 18 5 II 21 5.1 II...................................... 21 6 23 6.1...................................... 23 6.2........................................ 23 6.3...................................... 24 6.4......................................... 25 6.5................................ 27 7 III 29 7.1 III...................................... 29 1

8 31 8.1 1.................................... 31 8.2 (1 )............................... 32 8.3........................................ 34 8.4 scanf().................................... 35 8.5.......................................... 35 9 IV 37 9.1 IV...................................... 37 10 39 10.1 ( ).................................... 39 10.1.1.................................. 39 10.1.2..................................... 39 10.1.3.................................. 40 10.2 if.......................................... 40 10.2.1.................................. 42 10.2.2................................ 43 10.3 switch........................................ 44 11 V 46 11.1 V...................................... 46 12 47 12.1 for......................................... 47 12.2 break........................................ 50 12.3 continue....................................... 51 12.4 while........................................ 51 12.5 do-while....................................... 52 13 VI 53 13.1 VI...................................... 53 14 55 14.1.......................................... 55 14.2......................................... 56 14.3.................................... 57 15 VII 59 15.1..................................... 59 16 61 2

I (Version 17.0.1) 1 C C 1972 AT&T (Dennis M. Ritchie) C OS UNIX C 1.1 1 C 1.2 L A TEX ( ) pdf C ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz0123456789+- ( )!! 1.c.c ( ) bcpad ] 1 1

1.3 2 1.1. ( ) #include <stdio.h> int main(void) { printf("hello, C world!y=n"); return 0; ( ) 1.2. ( ]) 4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF... 1.4 ; 1 1 2, 3 1.1 #include <stdio.h> int main(void){printf("hello CY=n");return 0; 1 1.4.1 1.1 4 5 ( ) 1.3. #include <stdio.h> int main(void) { printf("hello CY=n"); return 0; 2 2

1.4.2 1.4. #include <stdio.h> int main(void){ int i,sum; sum=0; for(i=1;i<=10;i++){ sum=sum+i; printf("1 10 %d Y=n",sum); return 0; C ( ) 1 1.4 3 4 int main ( void ) { int i,sum ; ( ) int main(void){ int i, sum; intmain(void) int main(vo id) ( ) int ( ) main ( void ) {int i,sum ; 1 1 #include<stdio.h> # 3

1.4.3 ( ) 1 // /* */ 1.5. ( ) #include <stdio.h> int main(void) // main(void) { printf("hello CY=n"); return 0; /* */ 1.5 1.6. ( ( ) ) E2379 hello.c 5: ( ) ( main ) W8070 hello.c 7: ( main ) *** 1 errors in Compile *** (i) { ( ) ] 1 (ii) ; ] : (iii) ] (iv) { ] 1, C3( 20) 6 4

I 2 C 2.1 C 2.1. Hello C 1 #include <stdio.h> 2 int main(void) 3 { 4 printf("hello CY=n"); 5 return 0; 6 Hello C (1) bcpad (2) 1 #include <stdio.h> (.h) ( ) (stdio.h) 3 100% stdio.h C { (3) 2 main(void) main int void main() main(void) 3 6 3 Standard I/O(Input/Output) 5

main(void) int main(int argc, char *argv]) int main() void main() (4) main() 1 (stdio.h ).) fclose, fopen, printf, scanf, getc, getchar (5) main() 1 4 1 ( ; ) printf() () (6) 5 0 main() ( )MS Windows Linux OS OS 0 main() II 2.2. int sum(int a, int b) { return a+b; sum() 2 a=sum(10,20); z=sum(x*x,y*y); p=sum(sum(2,3),5); 6

2.2 printf I printf ) ( ) printf(, ); (abc,, ) Y=n %+ 10 %d 4.4 2.3.. 1 #include <stdio.h> 2 int main(void){ 3 printf("hello"); 4 printf("c"); 5 return 0; 6 HelloC 2.4.. 1 #include <stdio.h> 2 int main(void){ 3 printf("helloy=n"); 4 printf("c"); 5 return 0; 6 Hello C 2 3 Hello Y=n 2.4 3 4 3 printf("helloy=nc"); 2.4 7

( ) ( 4.4 ) int a, b int x( ) 2.5. 1. 1 #include <stdio.h> 2 int main(void){ 3 int a, b; 4 int x; 5 a=5; 6 b=3; 7 x=a+b; 8 printf("a=%dy=n",a); 9 printf("b=%dy=n",b); 10 printf("a+b=%dy=n",x); 11 return 0; 12 a=5 b=3 a+b=8 a, b, x %d %d 2.6. 2. 1 #include <stdio.h> 2 int main(void){ 3 int a, b; 4 a=5; 5 b=3; 6 printf("%d+%d=%dy=n",a,b,a+b); 7 return 0; 8 5+3=8 6 a+b a b 8

I 3 I 3.1 CPad(bcpad) CPad 4 CPad Borland C++ Compiler Windows GUI Cpad Borland C++Compiler bcpad bcpad (1) 1 OK] 2 1 2 (2) D:Y=Documents and SettingsY=usersY=My documentsy=c OK] 9

(3) (4) (F)] (A) (5) 1]* Hello.c (6) 2 (R)] make Ctrl] +F9] (7) (6) (R)] (make )(F) Shift] +F9] 10

3.2 I 3.0. 2.3 2.4 3.1. S15M999 ( ) :S15M999 : : printf() %d Y=n % Y= ( ) % Y=% " Y=" Y= Y= Y=Y= 3.2. %, 1 Y=150 5 "20% ",? ( ) 1 5 1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ ( ) 11

3.3. 1 #include <stdio.h> 2 int main(void) 3 { 4 printf("hello CY=n"); 5 return 0; 6 3.4. 3.1 3.3 1 ( ) :S15M999 : : 1 Y=150 5 "20% ",? 1 #include <stdio.h> 2 int main(void) 3 { 4 printf("hello CY=n"); 5 return 0; 6 3.5. ( ) (1), (2) (1) 1 2 3 4 5 6 7 8 9 -----+--+--+--+--+--+--+--+--+--+ 1 1 2 3 4 5 6 7 8 9 2 2 4 6 8 10 12 14 16 18 3 3 6 9 12 15 18 21 24 27 4 4 8 12 16 20 24 28 32 36 5 5 10 15 20 25 30 35 40 45 6 6 12 18 24 30 36 42 48 54 7 7 14 21 28 35 42 49 56 63 8 8 16 24 32 40 48 56 64 72 9 9 18 27 36 45 54 63 72 81 (2) ) ) / _ / ( / < L/ / 12

I 4 4.1 ( ) ( ) ( ) 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 ( 31 ) for data, DATA, Data 4.1. kadai 0510kadai kadai0510 kadai-0510 FOR fime_name FileName ( ) (- ) ( ) ( ) ( ) md MaxData MinData MonthData 4.2 C auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while include stdio.h printf scanf 13

4.2. 1 #include <stdio.h> 2 int main(void){ 3 int auto; 4 auto=5; 5 printf("auto %d Y=n",auto); 6 return 0; 7 4.3 C dt=100; dt 100 (= ) 4.3.1 10 8 16 (u, U, l, L, LL) 4.3. a 30 a=30; a=036; a=0x1e; a=30u;! LL(long long) L 4.3.2 e E 4.4. a 123.456 b 0.000123 a=123.456; a=1.23456e+02; b=0.000123; b=1.23e-04;! c=100f c=100.0f 0.00000000000123 14

4.3.3 ( A ) A A 4.5. (1) (2) int c; c= A ; // (1) c=65; // (2) 4.6. 1 #include <stdio.h> 2 void main(void){ 3 char c; 4 int n; 5 c= A ; 6 n=5; 7 printf("%c %d %c Y=n",c,n,c+n); 8 A 5 F! C a="moji" 8 char txt10]="hello"; // txt "Hello" strcpy(txt, "Hello"); // txt "Hello" 4.3.4 printf() Y=n Y= n ( ) Y=n ( ), Y=t ( ), Y=xhh (16 ) a=0x32 a= Y=x32 2 15

4.7. (1) printf("abcy=tklmy=nnopy=nsy=tty=tuy=n"); printf("y=tmnoy=n"); printf("123456y=t7890y=n"); printf("1234567y=t890y=n"); printf("12345678y=t90y=n"); abc klm nop s t u mno 123456 7890 1234567 890 12345678 90 8 1 (2) 16 printf("%dy=n", Y=x30 ); 48 16 30 10 (%d) if(i<=3286){ 3286 if(i<=maxdata){ (main() ) #define MaxData 3286 ( ; ) MaxData 3286 16

1 4.8. 1 max 1 #include <stdio.h> 2 #define max 10 3 int main(void){ 4 int i, sum=0, pro=1, sum2=0; 5 6 for(i=1;i<=max;i++) 7 sum+=i; 8 9 for(i=1;i<=max;i++) 10 pro*=i; 11 12 for(i=1;i<=max;i++) 13 sum2+=i*i; 14 15 printf("1 %d,, Y=n",max); 16 printf("%d, %d, %dy=n",sum,pro,sum2); 17 printf(" Y=n"); 18 return 0; 19 1 10,, 55, 3628800, 385 2 max 10 max 10 2 10 1 10(max) (6,7 ) (9,10 ) (12,13 ) #define main() 17

4.9. 1 #include <stdio.h> 2 #define wa(a,b) ((a)+(b)) 3 #define pri(dt) printf("%dy=n",dt) 4 5 int main(void){ 6 int c; 7 c=wa(10,20); 8 pri(c); 9 return 0; 10 30 const const const int dt=100; dt 100 // 4.4 printf II 2.2 printf printf(, ); : abc, 123,,, Y=t, Y=n : %d %s %+ ] 18

! %o 8 %d 10 %x 16 ( ) %X 16 ( ) %ld long 10 %f %e ( ) %E ( ) %c %s %p o d a=1;b=2;c=3; printf(" %d %d %d Y=n",a,b,c); 1 2 3 %. 4.10. #include<stdio.h> void main(void){ int a=2,b=13,c=321,d=21; printf("a=%4d,y=n",a); printf("b=%4d,y=n",b); printf("c=%4d,y=n",c); printf("c=%04d,y=n",d); 19

a= 2, b= 13, c= 321, d=0021, %4d %04d = 4 10 %d 10 %8d 8 10 0 %08d 8 10 0 %-8d 8 10 %f %10.2f (, 1 ) 10 2 4.11. #include<stdio.h> int main(void){ int a=20; double da=-12.3456789; printf("a=%8d,y=na=%08d,y=na=%-8d,y=n",a,a,a); printf("da=%fy=n",da); printf("da=%10.4fy=n",da); printf("da=%10.4fy=n",da*(-1)); return 0; a= 20, a=00000020, a=20, da=-12.345679 da= -12.3457 da= 12.3457 3 (a ) 8 3 (da ) ( )10 10 20

I 5 II 5.1 II 5.1. (1) #include<stdio.h> int main(void){ int a, c; double b; a=123; b=456.789; c=66; printf(" Y=n",a,a,a); printf(" Y=n",b,b,b); printf("%c,%c,%cy=n", ); return 0; 123,173,7b 456.789000,4.567890e+02,4.567890E+02 A,B,C (2) #include<stdio.h> int main(void){ int a; char c; c= G ; a=5; (i) (ii) c= P ; a=3; return 0; G 5 L G g P 3 S P p (i) (ii) 21

5.2. ( ) ( ) 3 / / / / 4 ( ) #include<stdio.h> int main(void){ int y=2017; int m1, d1, prec1; int m2, d2, prec2; int m3, d3, prec3; double high1, low1; double high2, low2; double high3, low3; m1=1; d1 = 15; prec1=0; high1=5.12; low1=-3.24; m2=8; d2 = 23; prec2=30; high2=36.33; low2=27.87; m3=9; d3 = 30; prec3=10; high3=26.00; low3=14.00; printf(" Y=n"); return 0; 36.330000, -3.240000 / / 2017/01/15 5.120000-3.240000 0% 2017/08/23 36.330000 27.870000 30% 2017/09/30 26.000000 14.000000 10% 22

I 6 6.1 C int a; double b; char c; a, b, c 6.2 C! char 1 128 127 unsigned char 1 0 255 (signed) int 4 2147483648 2147483647 unsigned (int) 4 0 4294967295 short (int) 2 32768 32767 unsigned short (int) 2 0 65535 long (int) 4 2147483648 2147483647 unsigned long (int) 4 0 4294967295 float 4 10 37 10 38, 6 double 8 10 307 10 308 15 ( ) printf("%dy=n", sizeof(char)); printf("%dy=n", sizeof(int)); C char 1 1 0 256 1 ( ) 2 1 23

6.3 int a; a 4 (a 4 ) int a; 1 4 a a 1 8 ( 0 1 8 ) 32 0 1 int int (4 ) 0 1 31 unsigned int int 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2147483647 +1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2147483648 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 0 0 0 0...... 0 1 1 1 1 1...... 1 0 +1 1 1 1 1...... 1 1 1 1 0 0 0...... 0 1 1 24

6.4 C,,,,,,, sizeof, 6.1. int a=10,b=3; printf("a+b=%dy=n",a+b); printf("a-b=%dy=n",a-b); printf("a*b=%dy=n",a*b); printf("a/b=%dy=n",a/b); printf("a%%b=%dy=n",a%b); + a+b a b - a-b a b * a*b a b / a/b a b % a%b a b a+b=13 a-b=7 a*b=30 a/b=3 a%b=1 2 & AND a&b a b OR a b a b ^ OR a^b a b >> a>>2 a 2 << a<<3 a 3 ~ ~a a 25

a=0,b=1 a&b=0,a b=1 a=3,b=5 a&b=1,a b=7,a^b=6 a=3, b=5 b a &b 0 1 a 0 0 0 1 0 1 b a b 0 1 a 0 0 1 1 1 1 b a b 0 1 a 0 0 1 1 1 0 a = 0 0 0 0 0 0 1 1, a&b = 0 0 0 0 0 0 0 1 b = 0 0 0 0 0 1 0 1, a b = 0 0 0 0 0 1 1 1 a^b = 0 0 0 0 0 1 1 0 a>>1; a<<2; a 2 a 4 a=11 a = 0 0 0 0 0 1 0 1 1, a>>1 = 0 0 0 0 0 0 1 0 1, a<<2 = 0 0 0 1 0 1 1 0 0 = = = a=b a b a a=3 3=a (BCpad ) 6.2. 1 int idt; 2 double ddt; 3 idt=2.7182; //idt 2 4 ddt=11.5; //ddt 11.500000 5 idt=ddt; //idt 11 6 ddt=idt; //ddt 11.000000 3 5 5 idt=(int)ddt; ddt int ( ) 26

++ a++ a 1 -- a-- a 1 ++ ++a a 1 -- --a a 1 1) a++, ++a a=a+1 2) c=a++; c=a; a++; 3) c=++a; ++a; c=a; 6.3. int a=10,b,c,d,e; b=++a; c=a++; d=--a; e=a--; printf("a=%d, b=%d, c=%d, d=%d, e=%dy=n",a,b,c,d,e); a=10, b=11, c=11, d=11, e=11 6.5 ++, -- ++, -- *, /, % +, - >>, << = 6.4. int a,b,c; b=3;c=5; a=b+++c; printf("%d,%d,%dy=n",a,b,c);,8, 4, 5 ( ) 27

6.5. 1 #include<stdio.h> void main(void){ int a,b; a=10; printf("(1)=%d,(2)=%dy=n",a++,++a); printf("(3)=%dy=n",a); printf("(4)=%d,(5)=%dy=n",++a,a++); printf("(6)=%dy=n",a); a=10;b=10; printf("(7)=%d,(8)=%dy=n",a++,++b); printf("(9)=%d,(10)=%dy=n",a,b); printf("(11)=%d,(12)=%dy=n",++a,b++); printf("(13)=%d,(14)=%dy=n",a,b); (1)=11,(2)=11 (3)=12 (4)=14,(5)=12 (6)=14 (7)=10,(8)=11 (9)=11,(10)=11 (11)=12,(12)=11 (13)=12,(14)=12 6.6. 2 #include<stdio.h> void main(void){ int s; double a,b; s=1234567890; a=1234567.890; b=0.123456789; printf("(1)=%f,(2)=%fy=n",a+b,a-b); printf("(3)=%e,(4)=%ey=n",a*b,a/b); printf("(5)=%10.4f,(6)=%8.3fy=n",a*b,a/b); printf("(7)=%d,(8)=%dy=n",s,s*s*s); printf("(9)=%f,(10)=%fy=n",4/3*3.14,3.14*4/3); (1)=1234568.013457,(2)=1234567.766543 (3)=1.524158e+05,(4)=1.000000e+07 (5)=152415.7875,(6)=10000000.000 (7)=1234567890,(8)=-1577654328 (9)=3.140000,(10)=4.186667 28

I 7 III 7.1 III 7.1. 2 a,b a,b #include<stdio.h> void main(void){ int a,b; a=10;b=4; 2*a+b=24 a-3*b=-2 a*b/b=10 b/a*a=0 a%b%a=2 7.2. 5 a1 a5 a1 a5 #include<stdio.h> void main(void){ int a1, a2, a3, a4, a5; double ave, vari; a1=4; a2=-3; a3=5; a4=12; a5=-2; 5 4, -3, 5, 12, -2 3.2 29.36 29

7.3. 2 a,b a b a,b 3 6 9.0 7.4. 2 30 (*********** ) 2 30 *********** 7.5. 2 1100110011001100 10 2 1100110011001100 10 *********** 7.6. 7 9 a 3, a a 12321012 a 12,321,012 7.7. 255 a 2 8 a a 87 87 2 01010111 7.8. (double ) d d d 18.5236 18.5236 19.0 18.5236 18.5 30

I 8 C ( ) getchar(), gets(), scanf() ( ) putchar(), puts(), printf() 8.1 1 1 getchar(), putchar() 1 8.1. getchar() 1 1 1 #include<stdio.h> 2 void main(void){ //void main return 0; 3 int ch; // char ch; 4 ch = getchar(); 5 putchar(ch); 6 putchar( Y=n ); 7 1 a a 2 putchar(ch); abc a putchar(ch); 8.2. getchar() 1 2 1 #include<stdio.h> 2 void main(void){ 3 int ch; 4 ch = getchar(); 5 putchar(ch); 6 putchar(ch); 7 a aa 5 6 putchar(ch); 31

8.2 (1 ) 1 gets(), puts() char ch100]; 1 (char ) 100 5 1 1 1 1 1 ch] ch0] ch1] ch2] ch98] ch99] 1 char ch100]="abc"; ch] a b c 0? ch0] ch1] ch2] ch3] ch4] ( ) 0 (ch3] 0 ) 0 8.3. 1 #include<stdio.h> 2 void main(void){ 3 char ch100]="abcdefg"; 4 5 printf("%sy=n",ch); 6 ch3]=0; 7 printf("%sy=n",ch); 8 ch3]= D ; 9 printf("%sy=n",ch); 10 abcdefg abc abcdefg 0 Y=0! ( ) 3 3 char ch100]; 4 ch100]="abcdefg"; 5 32

8.4. gets() 1 1 1 #include<stdio.h> 2 int main(void){ 3 char ch100]; 4 gets(ch); 5 puts(ch); 6 puts(ch); 7 return 0; 8 abc abc abc (4 ) 5 puts(ch); 6 puts(ch);.( ) puts() puts("") %c %s 3 char ch100]="abcdefg"; 4 printf("%c Y=n",ch); // NG 5 printf("%s Y=n",ch); // OK 6 printf("%c Y=n",ch1]); // OK 7 printf("%s Y=n",ch1]); // NG %c 1 %s 7 8.5. gets() 1 2 1 #include<stdio.h> 2 int main(void){ 3 char ch100]; 4 gets(ch); 5 printf("%sy=n",ch); 6 printf("%cy=n",ch2]); 7 return 0; 8 abc abc c 5 printf(); 6 printf(); 33

8.3 scanf() scanf() %d (int ) %lf (double ) %s (char ) %s ( ) 8.6. scanf() 1 #include<stdio.h> 2 void main(void){ 3 int n; 4 double d; 5 scanf("%d",&n); // n & 6 printf("%dy=n",n); 7 scanf("%lf",&d); //scanf double %lf 8 printf("%fy=n",d); 9 32 (5 ) 32 32.123 (7 ) 32.123000 8.7. scanf() 1 #include<stdio.h> 2 void main(void){ 3 char ch100]; 4 scanf("%s",ch); // & (&ch ) 5 printf("%sy=n",ch); 6 abc abc (4 ) 5 printf();! scanf() printf() scanf("n %d",&n); printf("n "); scanf("%d",&n); 34

scanf() ( fgets, sscanf) 8.4 scanf() scanf() 2 8.8. 1 #include <stdio.h> 2 int main(void){ 3 int a, b; 4 char ch; 5 printf(" a="); 6 scanf("%d",&a); 7 printf(" ="); 8 scanf("%c",&ch); 9 printf(" b="); 10 scanf("%d",&b); 11 return 0; 12 a=12345 = b=67890 5, 6, 7, 8 6 scanf() (Y=n) ch %c 1 8 scanf(" %c",&ch); scanf("%c %c %c",&a,&b,&c); 8.5 stdlib.h rand() rand() 0 RAND_MAX(32767) 35

8.9. (1) a 1 #include <stdio.h> 2 #include<stdlib.h> 3 int main(void){ 4 int a; 5 a=rand(); 6 return 0; 7 (2) 0 1 4 double b; 5 b=rand()/(rand_max+1.0); (3) 1 6 5 a=(int)(rand()/(rand_max+1.0)*6)+1; rand() srand() rand() srand() seed rand() seed 8.10. seed #include <stdio.h> #include <time.h> #include <stdlib.h> #include <windows.h> //Sleep int main(void){ srand(10); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); srand(10); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); srand((unsigned)time(null)); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); Sleep(1000); // 1000 srand((unsigned)time(null)); printf("%d,%d,%d,%dy=n",rand(),rand(),rand(),rand()); return 0; 8444,10368,10345,30957 8444,10368,10345,30957 3657,19254,31547,15483 14223,9362,9631,15268 36

I 9 IV 9.1 IV 9.1., : s16m999 : m : y s16m999my@ous.jp 9.2. a 5 f y 5 d : 5 : y y 5 d 9.3. (double ) 16.534 16.534 16 17 9.4. 1 100 10 10 seed srand() ( seed 13) 10 92, 30, 41, 22, 55, 37, 10, 75, 94, 17 47.3 9.5. 5 5 gs6v7 gs6v7 7v6Sg 37

9.6. (8%) 10% 1200 96 1296 129 9.7. 2 30 (n) 2 n 9.8. 2 a, b a 178 b 84 262, 94, 14952, 2, 10 9.9. 7 9 a 3, a (7 9 ) 163545343 a 163,545,343 9.10. 255 a 8 2 9.11. -100 100 6 3 2 2 2 (x1,x2,x3)=( 12.40, 10.34, -3.00) (y1,y2,y3)=( 81.34, -34.50, 27.90) (x,y)=-310.664000 9.12. ( ) ( ) (n) n qwertyuiop 5 qwertyuiop 5 t 38

I 10 10.1 ( ) 10.1.1 (if for while ) ( ) 10.1. a<1 b>=12 a==b a!=b < a<b a b <= a<=b a b > a>b a b >= a>=b a b == a==b a b!= a!=b a b ( ) 10.2. 1 if(a<1) for(;b>=12;) if(a==b) while(a!=b) 10.1.2 (true) (false) 1 0 : a==10 : a 10 : a 10 0 0 39

10.3. 2 #include<stdio.h> void main(){ int a; a=0; printf("%dy=n",a==5); a=5; printf("%dy=n",a==5); 0 1 10.1.3 10.4. (a>=3 && a<10) (a!=b b>5) (!(a<=b)) && (AND) a&&b a b (OR) a b a b! (NOT )!a a // (a 3 a < 10 a ) // (a b, 5 < b ) // (a > b) 10.2 if if ( 1, 2) { if( ) ; if( ) 1 else 2 ; 1 2 if if-else 40

10.5. if 1 1) if(a>10) printf("a 10 Y=n"); 2) if(a>10) printf("a 10 Y=n"); else printf("a 10 Y=n"); 3) if(a>10 && a%2==0){ printf("a 10 Y=n"); printf(" a Y=n"); 10.6. if 2 scanf("%d",&a); if(a) printf("a 0 Y=n"); a a 0! if ( ) 1 10.7. if 3 a=0; if(a==1) printf("a 1 Y=n"); printf("a 0 Y=n"); a 0 10.8. if 4 ( { ) a=0; if(a==1){ printf("a 1 Y=n"); printf("a 0 Y=n"); 2 printf! 41

if else else if if( A){ 1; else if( B){ 2; else if( C){ 3; else{ 4; A 1 B 2 C 3 4 10.9. if 5 1) if(a>10) printf("a 10 Y=n"); else if(a%2==0) printf("a 10 Y=n"); else printf("a 10 Y=n"); 2) if(b%4==0) printf("b 4 Y=n"); else if(b%4==1) printf("b 4 1 Y=n"); else if(b%4==2) printf("b 4 2 Y=n"); else printf("b 4 3 Y=n"); 10.2.1 if? : a?b:c a b c 10.10..( N ) (N%2 == 0)? even++ : odd++; 42

10.2.2 C a=a+3; b=b*c; += a+=b a b a (a=a+b ) -= a-=b a b a (a=a-b ) *= a*=b a b a (a=a*b ) /= a/=b a b a (a=a/b ) %= a%=b a b a (a=a%b ) >>= a>>=b a b a <<= a<<=b a b a &= a&=b a b a = a =b a b a ^= a^=b a b a = = a+=3; b*=c; 10.11. #include<stdio.h> void main(){ int a=0; a+=10; printf("%dy=n",a); a++; printf("%dy=n",a); a-=3; printf("%dy=n",a); a<<=3; printf("%dy=n",a); 10 11 6 48 43

10.3 switch if 2 switch switch( A){ case 1: 1 break; case 2: 2 break; case 3: 3 break;...... default: n A case 1 case 2 case 3 default 1 2 3 n A ( switch(a) switch(i+5) ) 1, 2, 3 A A 1, 2, 3 A 1, 2, 3 default! case 1, case 2, case 3, default ( : ) 10.12.. scanf("%d", &n); switch(n){ case 2: printf(" 2 Y=n); break; case 3: printf(" 3 Y=n); break; case 6: printf(" 6 Y=n); break; default: printf(" 2,3,6 Y=n); 44

10.13. double n; switch(n){ case 1.5: printf(" 1.5 Y=n);...... case break break case switch( A){ case 1: 1 case 2: 2 break; case 3: 3 default: 4 A case 1 case 2 case 3 default 1 2 3 4 A 1 1 2 A 2 2 10.14. case scanf("%d", &n); switch(n){ case 2: case 3: case 5: case 7: printf(" 10 Y=n); break; default: printf(" 10 Y=n); n 2, 3, 5, 7 case 7: n 2, 3, 5, 7 default: 45

I 11 V 11.1 V 11.1. 4 (y) y ( ) (i) 4 (ii) 100 (iii) 400 1 2100 2100 2 2800 2800 11.2. 5 5 ag8hy Ag8Hy 11.3. ( ) a op b op +( ), -( ), *( ), /( ), %( ) switch ] 1 (a=): 26 (+,-,*,/,%) 1 : % 1 (b=): 4 26 % 4 2 ] 1 (a=): 6 (+,-,*,/,%) 1 : $ 1 (b=): 8 46

I 12 12.1 for for for( 1 ; 2 ; 3 ) ; for (1) 1 (2) 2 (4) (3) 3 (2) (4) for 1, 2, 3 12.1. for 1) for(i=1;i<=10;i++) 2) for(i=1;i<10;j+=2) 3) for(i=1;(i<10&&j<5);i++) 4) for(;i!=0;) 1 2 3 n ( ) 12.2. 1 ( { ) for(i=1;i<=3;i++){ printf(" Y=n"); 12.3. 2 ( { ) for(i=1;i<=3;i++) printf("%d Y=n",i); 1 2 3 47

! for if 1 { 1 12.4. 3 pow=1; for(i=1;i<=5;i++){ pow*=2; printf("2 %d %d Y=n",i,pow); 2 1 2 2 2 4 2 3 8 2 4 16 2 5 32 12.5. 4 2 5 (??) pow=1; for(i=1;i<=5;i++) pow*=2; printf("2 %d %d Y=n",i,pow); 2 6 32 ( 3) i++, ++i, i+=1, i=i+1 1 i--, i=i-1, i*=2, i/=2 1 2, 1, 2 ( 2) i<10 i<=10 i 10 i 10 12.5. for (i 11 for ) 48

12.1. 3) 12.6. (i 100 sum 1000 for ) sum=0; for(i=1;(i<=100)&&(sum<1000);i++) sum+=i; 12.7. ( for ) sum=0; for(i=1;!(sum<0);i++) sum+=i; for for ( ) 12.8. for 2 ( ) 1 #include<stdio.h> 2 int main(void){ 3 int i,j; 4 printf(" 1 2 3 4 5 6 7 8 9 Y=n"); 5 printf("-----+--+--+--+--+--+--+--+--+--+y=n"); 6 for(i=1; i<=9; i++){ 7 printf("%d ",i); 8 for(j=1;j<=9; j++) 9 printf("%2d ",i*j); 10 printf("y=n"); 11 12 return 0; 13 1 2 3 4 5 6 7 8 9 -----+--+--+--+--+--+--+--+--+--+ 1 1 2 3 4 5 6 7 8 9 2 2 4 6 8 10 12 14 16 18 3 3 6 9 12 15 18 21 24 27 4 4 8 12 16 20 24 28 32 36 5 5 10 15 20 25 30 35 40 45 6 6 12 18 24 30 36 42 48 54 7 7 14 21 28 35 42 49 56 63 8 8 16 24 32 40 48 56 64 72 9 9 18 27 36 45 54 63 72 81 49

1 for (7 12 ) i 2 for (9,10 ) j i 1 2 3 4 5 6 7 8 9 -----+--+--+--+--+--+--+--+--+--+ 1 1 4 9 16 25 36 49 64 81 12.2 break break for 12.9. 0 break 1 #include<stdio.h> 2 void main(void){ 3 int sum=0; 4 int n; 5 for(;;) 6 { 7 scanf(" %d",&n); 8 if (n==0)break; 9 sum+=n; 10 11 printf(" %d Y=n",sum); 12 5-3 12 0 // 0 14 6 10 for 0 break if 50

12.3 continue break switch for continue for 12.10. for continue if 1 #include<stdio.h> 2 void main(){ 3 int i; 4 for(i=1;i<=30;i++){ 5 6 if(i%2!=0 i%3!=0) continue; 7 printf("%2d 6 Y=n",i); 8 9 f1 f2 A f3 6 i 2 3 for for 3 5 continue 12.11. switch continue if 13 switch(i%2){ 14 case 0: 15 printf("i "); 16 if (i%4==0) continue; 17 printf(" 4 0 "); 17 i 2, 6 ( continue break ) 12.4 while while for while( ) ; for while for ( ) while while for 2 while(i<=10){ for(;i<=10;){ 51

for(i=1;i<=10;i++){ ; while i=1; while(i<=10){ ; i++; 12.12. while 1) while(i<=1000) 2) while(i!=0) 3) while(i>=j) 4) while(1) //break! while 1 12.5 do-while do-while while do while( ); while do-while do-while 1! while ; 12.13. g #include<stdio.h> void main(void){ int i=0; char m50]="abcdefghijk"; do { printf("%c",mi]); while(mi++]!= g ); 52

I 13 VI 13.1 VI 13.1. 10000 10000 12347 12347 13.2. 10000 10000 12347 12347 1,12347 13.3. 4 ( ) 1. a 5 f y 5 d : math : 15 "bpiw" : qwer : 12 "ciqd" :.fin 13.4. ( ) 1 10 2 7 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 53

13.5. 2 2 : 14 2 : 35 14 35 7 13.6.. : ab1 Ab1 : a1fg4rkju90 A1FG4rKJU90 :. 13.7. 10 10 15-4 0 3-4 20-14 15-6 7 10 15, -4, 0, 3, -4, 20,-14, 15, -6, 7 3.2 20, -14 13.8. 2 2 : 500 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 54

I 14 14.1 ( ) int a10]; double b10]; ] 10 0 9 14.1. int f10]; f0]=1;f1]=1;f2]=2;f3]=3; 1 2 3 2 int a10]20]; a0]0] a0]1] a0]2]... a0]19] a1]0] a1]1] a1]2]... a1]19]....... a9]0] a9]1] a9]2]... a9]19] 14.2. a0]0],a0]1],a1]0],a1]1] det=a0]0]*a1]1]-a1]0]*a0]1]; printf(" %f Y=n", det); 14.3. 10 int data100]; int i; for(i=0;i<10;i++){ scanf(" %d",&datai]);! 2 temp=dataj]; dataj]=datai]; datai]=temp; dataj]=datai]; datai]=dataj]; 55

14.2 (10,11 ) 6 int d3]={1,2,3; 7 int e2]3]={{1,2,3,{4,5,6; 8 char f]={ A, B, C ; 9 char g10]="abcdef"; 10 int h3]={0,1,2,3; // 11 char i3]="abcde"; // ( ) bcpad 1 14.4. #include<stdio.h> int main(void){ int i; int data10]={1,2,5,-3,2,6,-4,3,-6,2; for (i=0; i<10; i++){ printf("data%d] = %dy=n", i, datai]); return 0; 14.5. #include<stdio.h> void main(){ int data10]={1,2,5,-3,2,6,-4,3,-6,2; int i,temp; for(i=0;i<10;i++) printf("%2d,",datai]); printf("y=n"); i=0; while(i<9){ i++; if(datai-1]<datai]){ temp=datai-1]; datai-1]=datai]; datai]=temp; i=0; for(i=0;i<10;i++) printf("%2d,",datai]); printf("y=n"); 1, 2, 5,-3, 2, 6,-4, 3,-6, 2, 6, 5, 3, 2, 2, 2, 1,-3,-4,-6, 56

14.3 C #include<string.h> strcpy(ss, st) strcat(ss, st) strcmp(st1, st2) strlen(st) strncpy(ss, st, n) strncat(ss, st, n) strcmp(st1, st2, n) ss st ss st st1 st2 st1 > st2 st1 < st2 st1=st2 0 ss st n ss st n st1 st2 n strcmp(ss, st) 14.7 ( ) strcpy(ss,st) strcat(ss,st) strcmp(st1,st2) strlen(st) 14.6. 1 #include<stdio.h> 2 #include<string.h> 3 void main(void){ 4 char a]="abc"; 5 char b]="def"; 6 printf(" Y="%sY=" %d Y=n", a, strlen(a)); 7 strcpy(a,b); 8 printf(" Y="%sY=" %d Y=n", a, strlen(a)); 9 strcat(a,b); 10 printf(" Y="%sY=" %d Y=n", a, strlen(a)); 11 "abc" 3 "def" 3 "defdef" 6 57

14.7. strcmp ( ) 1 #include<stdio.h> 2 #include<string.h> 3 int main(void){ 4 printf("1) %dy=n", strcmp("abc","abc")); 5 printf("2) %dy=n", strcmp("abc","abd")); 6 printf("3) %dy=n", strcmp("abc","aaaa")); 7 printf("4) %dy=n", strcmp("abc","ab")); 8 printf("5) %dy=n", strcmp("ab","cc")); 9 printf("6) %dy=n", strcmp("ab","ab")); 10 return 0; 11 1) 0 2) -1 3) 1 4) 67 5) -2 6) -32 ( ) A B C D E F... Z a b c d e... z 65 66 67 68 69 70... 90 97 98 99 100 101... 122 1) 2 strcmp() 0 2) C D -1 4) AB C C 67 6) A a -32 strncpy(ss,st+k,n); ss st k (k + 1 ) n strncpy(ss,st+3,5); st 3 (0,1,2,3 4 ) 5 ss a] "abcdefghijklmn" strncpy(b,a+3,5); b] "defgh" 58

I 15 VII 15.1 15.1. (.) 20 b38khur 7 GH3AGa-2435R 12.bye 15.2. : 2000 : 3 : 1 2000 3 1 2000 61 15.3. (2 10) 1 1000 (1) (2 10) : 2 2 1000 1024 (2) (2 50) : 7 7 1000 343 15.4. : AthLb+h430gaE153g*ok-Ovm 013345AabEgghhkLmOotv+*- 59

15.5. 10 20 2 1 a1fg4rkju90 kju90a1fg4r 15.6. 2 (1): Uchida (2): Uchinashi Uchida Uchinashi 5 d n 15.7. (1) 01 20 (0.00 10.00) (20 ) (1) seed srand() (2) (1) (2) (1) 01 4.72 02 7.55 03 3.75 04 5.92 05 0.34 06 1.22 07 8.18 08 0.61 09 9.18 10 6.70 (2) 05 0.34 08 0.61 06 1.22 03 3.75 01 4.72 04 5.92 10 6.70 02 7.55 07 8.18 09 9.18 15.8. ( ) 2 100 1 2 3 1 2 100 : 3 3, 10, 5, 16, 8, 4, 2, 1, 7 2 5 3 1 2 60