Size: px
Start display at page:

Download ""

Transcription

1 C V C

2

3 NULL sizeof strlen strcat

4 1 6 C hoge C int hoge int hoge; hoge int hoge hoge 6.1 hoge hoge 100 p_piyo p_piyo hoge

5 : 6.: hoge p piyo

6 6 int int double double double int int p piyo int* p_piyo; int *p_piyo; int *p_hoge,*p_piyo p hoge p piyo int* p_hoge, p_piyo p hoge p piyo int 6. int hoge; int int hoge 100 int* p_piyo 6.3 p piyo 3

7 6. 6.3: int hoge; int* p_piyo; hoge = 10; p_piyo = &hoge; int hoge int( hoge hoge = 10; hoge 10 p_piyo p_piyo = hoge; 6.4 p_piyo int* int* (int ( 6.4: p_piyo hoge & p_piyo = &hoge 6.5 4

8 6 6.5: & &hoge hoge int main(void) 5 int hoge; 6 int* p_piyo; 7 8 hoge = 10; 9 p_piyo = &hoge; printf("hoge address :%p\n", &hoge); 1 printf("hoge :%d\n", hoge); 13 printf("p_piyo :%p\n", p_piyo); 14 printf("*p_piyo:%d\n", *p_piyo); 15 printf("p_piyo address :%p\n", &p_piyo); 16 } printf %p 6.6 5

9 : printf("hoge address :%p\n",&hoge); & hoge address : printf("hoge :%d\n",hoge); hoge printf("p_piyo :%p\n",p_piyo); p_piyo printf("*p_piyo:%d\n",*p_piyo); *p_piyo *p_piyo : 10 hoge *p_piyo p_piyo p_piyo hoge *p_piyo * * int* p_hoge; /* * */ OS hoge address :001F580 6

10 6 int piyo = 10; p_hoge = &piyo; /* p_hoge piyo * */ printf("%d", *p_hoge); * * printf("p_piyo address :%p\n", &p_piyo); hoge address : 100 hoge : 10 p_piyo : 100 *p_piyo : 10 p_piyo address : 150 C void* 1 int main(void) { 3 int hoge = 10; 4 void* p_piyo = &hoge; 5 6 /* bar = *p_piyo */ 7 int bar = *( (int*)p_piyo ); 8 9 return 0; 10 } int bar = *p_piyo; 7

11 6.4 NULL p piyo ( hoge) int* p_piyo hoge *p_piyo 6.7: 6.4 NULL int hoge; printf("%d",hoge); hoge int* p p p 8

12 6 p = NULL; p NULL p NULL NULL #define NULL 0 p = NULL p = 0 p = 0 #define NULL ( (void*)0 ) NULL int* p = NULL printf("%d",*p); p 3 int* int* p_piyo = 10; NULL 0 int* p_piyo = 0; C 0 0 NULL swap 1 void swap( int x, int y ) { 3 int tmp = x; NULL 3 Java NullPointerException 4 0 NULL JAVA null 9

13 6.5 4 x = y; 5 y = tmp; 6 } 3 void swap( int x, int y ) 5 int tmp = x; 6 x = y; 7 y = tmp; 8 } 9 10 int main(void) 11 { 1 int hoge = 10, piyo = 5; swap( hoge, piyo ); 15 printf("hoge : %d, piyo : %d\n",hoge, piyo); 16 return 0; 17 } hoge : 10, piyo : 5 swap.?? 6.8 x y hoge piyo 10

14 6 6.8: 3 void swap(int* x, int* y); /* */ 4 5 int main(void) 6 { 7 int hoge = 10, piyo = 5; 8 9 swap( &hoge, &piyo ); 10 printf("hoge : %d, piyo : %d\n",hoge,piyo); 11 return 0; 1 } void swap(int* x, int* y) 15 { 16 int tmp = *x; 17 *x = *y; 18 *y = tmp; 19 } 6.9 *x hoge *y piyo hoge : 5, piyo : 10 hoge piyo &hoge scanf 11

15 : & 6.6 int char double?? : short int long unsigned short unsigned int unsigned long char unsigned char float 3.4 * 10^ * 10^+38 double 1.7 * 10^ * 10^+308 1

16 6 int char char 1 int char char sizeof sizeof sizeof int return int main(void) 3 { 4 char hoge; 5 int piyo; 6 7 printf("char %d ", sizeof(hoge) ); 8 printf("int %d ", sizeof(piyo) ); 9 return 0; 10 }

17 6.6 char 1 int int main(void) 3 { 4 char* p_hoge; 5 int* p_piyo; 6 7 printf("char* %d \n", sizeof(p_hoge) ); 8 printf("int* %d \n", sizeof(p_piyo) ); 9 return 0; 10 } char* 4 int* int main(void) 3 { 4 int array[5] = {5,10,15,0,5}; 5 int* p; 8 int* char* 14

18 6 6 p = &array[0]; 7 8 printf("p[0] = %d\n",*p); 9 p++; 10 printf("p[1] = %d\n",*p); 11 } main : 6.11: 15

19 6.6 Array[0] 100 int 4 Array[1] 104 p++; p int p++; : 4 int* char* =101 p[0] = 5 p[1] = 10 16

20 int main(void) 5 int array[5] = { 1,, 3, 4, 5 }; 6 int* p; 7 8 p = &array[0]; 9 10 printf("*(p+0) : %d\n", *(p + 0) ); 11 printf("*(p+1) : %d\n", *(p + 1) ); 1 printf("*(p+3) : %d\n", *(p + 3) ); 13 return 0; 14 } int array[5] = { 1,, 3, 4, 5 }; int* p; p = &array[0]; 6.13 array[0] 100 int 4 array[1] 104 array array[0] array[4] 5 array array[4] 116 int* p p = array[0]; 17

21 : array[0] int p int* (int) int* array[0] p = &array[0]; & array[1] p p = &array[1]; printf("*(p+0) : %d\n", *(p+0) ); printf("*(p+1) : %d\n", *(p+1) ); printf("*(p+3) : %d\n", *(p+3) ); *p p 100 *p 100 array[0] *(p + 0) *(p) *p p

22 6 6.14: printf("*(p+0) : %d\n", *(p+0) ); array[0] 1 printf("*(p+0) : %d\n", *(p+1) ); p int size 4 p+1 int 4 p p+1 p 100 int *(p+0) *(100 ) *(p+1) *( ) *(104 ) array[1] printf("*(p+0) : %d\n", *(p+3) ); *(p+0) : 1 *(p+1) : *(p+3) : 4 19

23 6.7 *( p + 1 ); p int main(void) 5 int array[5] = { 1, 5, 10, 15, 0 }; 6 int* p; 7 8 p = &array[0]; 9 printf("array[0] : %d\n", *(p + 0) ); 10 printf("array[1] : %d\n", *(p + 1) ); 11 1 printf("*p+1 : %d\n", *p + 1 ); return 0; 15 } array[0] : 1 array[1] : 5 *p+1 : *(p + 1) *p * (3 + 5) 9 C *p + 1 * + * *p *p printf("*p+1 : %d\n", *p + 1 ); p 1 0

24 6 printf("*p+1 : %d\n", *(p + 1) ); 3 int main(void) 5 int array[5] = { 1,, 3, 4, 5 }; 6 int* p; 7 8 p = &array[0]; 9 10 printf("*(p+0) : %d\n", *(p+0) ); 11 printf("*(p+1) : %d\n", *(p+1) ); 1 printf("*(p+3) : %d\n", *(p+3) ); 13 return 0; 14 } p = &array[0]; p = array; 3 int main(void) 5 int array[5] = { 1,, 3, 4, 5 }; 6 int* p; 7 8 p = array; /* p array */ 9 10 printf("*(p+0) : %d\n", *(p+0) ); 11 printf("*(p+1) : %d\n", *(p+1) ); 1

25 6.7 1 printf("*(p+3) : %d\n", *(p+3) ); 13 return 0; 14 } array p int main(void) 5 int array[5] = { 1,, 3, 4, 5 }; 6 int* p; 7 8 p = array; /* p array */ 9 10 printf("p[0] : %d\n", p[0] ); 11 printf("p[1] : %d\n", p[1] ); 1 printf("*(p+1) : %d\n", *(p + 1) ); 13 return 0; 14 } p[0] : 1 p[1] : *(p+1) : p[0] p array p[0] *(p + 0) p[1] *(p + 1) *(p + 1) p[1]

26 6 3 int main(void) 5 int array[5] = { 1,, 3, 4, 5 }; 6 int* p; 7 8 p = &array[1]; /* array[1] */ 9 10 printf("p[0] : %d\n", p[0] ); 11 printf("p[1] : %d\n", p[1] ); 1 printf("p[-1]: %d\n", p[-1] ); 13 return 0; 14 } p[0] : p[1] : 3 p[-1]: 1 p[-1] array[-1] p[-1] *(p - 1) *(p + 1) *(1 + p) (3 + 5) (5 + 3) *(1 + p) 1[p] int i; 3 void myputs(char str[0]) 3

27 6.7 5 int i; 6 for( i = 0; str[i]!= \0 ; i++ ) { 7 putchar( str[i] ); 8 } 9 printf("\n"); 10 } 11 1 int main(void) 13 { 14 char str[0] = "Hello world"; 15 myputs( str ); 16 return 0; 17 } Hello world myputs str char str[0] char* str main int main(void) { char str[0]; char* str; } str str char str[0] char* str myput void myputs(char* str) { int i; for( i = 0; str[i]!= \0 ; i++ ) { putchar(str[i]); 4

28 6 } } printf("\n"); void myputs(char str[]) void myputs(char* str); void myputs(char str[0]); void myputs(char str[]); myputs( str ); myputs( &str[0] ) main char str[10000]; myputs int array[5] int 5 int* p[5] int* 5 5

29 6.7 3 int main(void) 5 int array[5] = {1,, 3, 4, 5}; 6 int* p[5]; 7 int i; 8 9 for(i = 0; i < 5 ; i++) { 10 p[i] = &array[i]; 11 printf("p[%d] : %p\n", i, p[i]); 1 } *p[0] += 10; for(i = 0; i < 5 ; i++) { 17 printf("*p[%d] : %d\n", i, *p[i]); 18 } 19 } for array[i] p[i] p[i] 6.15 for p[0] : 100 p[1] : 104 p[] : 108 p[3] : 11 p[4] : 116 *p[0] += 10 p[0] array[0] 10 for *p[i] p[i] 6

30 6 6.15: p[0] : 100 p[1] : 104 p[] : 108 p[3] : 11 p[4] : 116 *p[0] : 11 *p[1] : *p[] : 3 *p[3] : 4 *p[4] :

31 6.8 3 int main(void) 5 char* str = "Hello"; 6 printf("%s\n", str ); 7 8 return 0; 9 } Hello 6.16 str 6.16: char* str = "Hello" char str[10] = "Hello" 6.17 str char str 8

32 6 6.17: 3 int main(void) 5 char* str = "Hello"; 6 char str[10] = "Hello"; 7 8 str[0] = B ; /* */ 9 str[0] = B ; /* OK */ return 0; 1 } str[0] *(str + 0) str str[0] = B str 9

33 char int char* int* 3 int main(void) 5 int hoge = 10; 6 int* p_hoge; 7 int** p_p_hoge; 8 9 p_hoge = &hoge; 10 p_p_hoge = &p_hoge; 11 1 printf("hoge = %d\n", hoge); 13 printf("*p_hoge = %d\n", *p_hoge); 14 printf("p_hoge address = %p\n", &p_hoge); 15 printf("p_p_hoge = %p\n", p_p_hoge); 16 printf("**p_p_hoge = %d\n", **p_p_hoge); return 0; 19 } : 30

34 6 6.19: p hoge hoge p p hoge int* p p hoge p hoge hoge : **p p hoge *( *p p hoge ) *( p hoge ) hoge = 10 *p_hoge = 10 p_hoge address = 150 p_p_hoge = 150 **p_p_hoge = 10 31

35 strlen strlen my strlen my strlen 3 int my_strlen(const char* str) 5 int i = 0; 6 while( *str++ ) { 7 i++; 8 } 9 return i; 10 } 11 1 int main(void) 13 { 14 char str[0] = "Hello world"; 15 printf("%s %d \n", str, my_strlen(str)); 16 return 0; 17 } const char* str my strlen str[i] = E ; *(str + i) = E ; *str++; *(str++); NULL NULL \0 0. while( 0 ) 3

36 strcat strcpy my strcpy 3 void my_strcpy(char* dest, const char* src) 5 while( *dest++ = *src++ ) 6 ; 7 } 8 9 int main(void) 10 { 11 char str[0] = "Hello world"; 1 char copy[0]; my_strcpy(copy, str); 15 printf(" %s \n",copy); 16 return 0; 17 } int main(void) 5 int hoge = 30; 6 int* piyo = &hoge; 7 8 printf("out1 :%d\n",hoge); 9 printf("out :%d\n",*piyo); 33

37 return 0; 1 } 3 int main(void) 5 int x = 10; 6 int y = 0; 7 int* hoge = &x; 8 int* piyo = &y; 9 int* tmp; tmp = hoge; 1 hoge = piyo; 13 piyo = tmp; printf("out1 :%d\n",x); 16 printf("out :%d\n",*hoge); return 0; 19 } 3 3 int main(void) 5 int array[5] = {1,,3,4,5}; 6 int* p = &array[0]; 7 34

38 6 8 p += ; 9 printf("out1 :%d\n",*p); return 0; 1 } 4 3 int main(void) 5 int array[5] = { 1, 5, 10, 15, 0 }; 6 int* p; 7 8 p = &array[0]; 9 10 printf("%d %d %d %d %d\n",*(p+0), *(p+1), p[], 3[p], *p ); 11 p = array; 1 printf("%d %d %d %d %d\n",*(p+0), *(p+1), p[], 3[p], *p ); *p += 10; 15 printf("p[0] : %d\n",p[0]); (*p)++; 18 printf("*p : %d\n",*p); 19 0 *(p++); 1 printf("*p : %d\n",*p); } 5 35

39 int main(void) 5 char* p = "Hello world"; 6 7 printf("%s\n",p); 8 p[1] = a ; 9 printf("%s\n",p); return 0; 1 } 6 hoge 100 i 00 j 300 k int main(void) 5 int hoge = 10; 6 int* i = &hoge; 7 int** j = &i; 8 int*** k = &j; 9 10 printf("hoge = %d\n", hoge); 11 printf("&hoge= %p\n", &hoge); 1 printf("*i = %d\n", *i); 13 printf("&i = %p\n", &i); 14 printf("&j = %p\n", &j); 15 printf("*j = %p\n", *j); 16 printf("**j = %d\n", **j); 17 printf("k = %p\n", k); 18 printf("*k = %p\n", *k); 19 printf("**k = %p\n", **k); 0 printf("***k = %d\n", ***k); 1 return 0; 3 } 36

40 37 [1] Brian W. Kernighan, Dennis M. Ritchie, The C Programming Language Second Edition [] Peter van der Linden, Expert C Programming Deep C Secrets [3], C [4] Bjarne Stroustrup, C++ [5], [6], [7], C [8], C [9], C [10], C [11], 006, [1] Ryo Kawahara, C/C++, [13] TOMOJI, C, [14], C, [15], C,

joho07-1.ppt

joho07-1.ppt 0xbffffc5c 0xbffffc60 xxxxxxxx xxxxxxxx 00001010 00000000 00000000 00000000 01100011 00000000 00000000 00000000 xxxxxxxx x y 2 func1 func2 double func1(double y) { y = y + 5.0; return y; } double func2(double*

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言語 ポインタ完全攻略

新・明解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

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

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

‚æ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

超初心者用

超初心者用 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

untitled

untitled C -1 - -2 - concept lecture keywords FILE, fopen, fclose, fscanf, fprintf, EOF, r w a, typedef gifts.dat Yt JZK-3 Jizake tsumeawase 45 BSP-15 Body soap set 3 BT-2 Bath towel set 25 TEA-2 Koutya

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

10

10 2: http://www7.bpe.es.osaka-u.ac.jp/~kota/classes/jse.html kota@fbs.osaka-u.ac.jp 10 : 0 1 2 n 2 n 0 1 1 0 1 0 0 1 (2) = 105 1 = 8 1 2 8 = 256 0 9 105 i 106 j 256 2 1 #include int main(void)

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

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

02: 変数と標準入出力

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

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

tuat1.dvi

tuat1.dvi ( 1 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 6 23 ( 1 ) 1 / 58 C ( 1 ) 2 / 58 2008 9 2002 2005 T E X ptetex3, ptexlive pt E X UTF-8 xdvi-jp 3 ( 1 ) 3 / 58 ( 1 ) 4 / 58 C,... ( 1 ) 5 / 58 6/23( )

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

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

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

C C UNIX C ( ) 4 1 HTML 1

C C UNIX C ( ) 4 1 HTML 1 C 2007 4 18 C UNIX 1 2 1 1.1 C ( ) 4 1 HTML 1 はじめ mkdir work 作業用ディレクトリーの作成 emacs hoge.c& エディターによりソースプログラム作成 gcc -o fuga hoge.c コンパイルにより機械語に変換 コンパイルエラー./fuga 実行 実行時エラー 完成 1: work hooge.c fuga 1 4 4 1 1.

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

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

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

Microsoft Word - no14.docx

Microsoft Word - no14.docx 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",

More information

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

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B A/B (2018/10/19) 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 10 19 A/B 1 2018 10 19 2 1 1 1.1 OHP.................................... 1

More information

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

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 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 C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................

More information

Prog1_10th

Prog1_10th 2012 年 6 月 20 日 ( 木 ) 実施ポインタ変数と文字列前回は, ポインタ演算が用いられる典型的な例として, ポインタ変数が 1 次元配列を指す場合を挙げたが, 特に,char 型の配列に格納された文字列に対し, ポインタ変数に配列の 0 番の要素の先頭アドレスを代入して文字列を指すことで, 配列そのものを操作するよりも便利な利用法が存在する なお, 文字列リテラルは, その文字列が格納されている領域の先頭アドレスを表すので,

More information

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

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 1. 1.1. 1.2. 1 PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU 2. 2.1. 2 1 2 C a b N: PC BC c 3C ac b 3 4 a F7 b Y c 6 5 a ctrl+f5) 4 2.2. main 2.3. main 2.4. 3 4 5 6 7 printf printf

More information

tuat2.dvi

tuat2.dvi ( 2 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 7 7 ( 2 ) 1 / 54 (1) (2) (?) (1) (2) 2 ( 2 ) 2 / 54 1. 30 2. 2012 6 30 25 OS ( 2 ) 3 / 54 10 20 1993 1996 2000 2003 = 30 ( 2 ) 4 / 54 1 2 2 ( 2 ) 5 /

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

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) 2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test

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

02: 変数と標準入出力

02: 変数と標準入出力 C プログラミング入門 基幹 7 ( 水 5) 1 12: コマンドライン引数 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/teachers/w48369 2/CPR1/ 2017-07-05 まとめ : ポインタを使った処理 2 内容呼び出し元の変数を書き換える文字列を渡す 配列を渡すファイルポインタ複数の値を返す大きな領域を確保する

More information

Informatics 2014

Informatics 2014 C 計算機の歴史 手回し計算機 新旧のソロバン バベッジの階差機関 スパコン ENIAC (1946) パソコン 大型汎用計算機 電卓 現在のコンピュータ Input Output Device Central Processing Unit I/O CPU Memory OS (Operating System) OS Windows 78, Vista, XP Windows Mac OS X

More information

P05.ppt

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

More information

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

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

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

C Nishio, Quick http://karetta.jp/book-cover/c-for-beginners http://www.usamimi.info/ guiprog/ C 1972 AT&T Dennis M. Ritchie Brian Wilson Kernighan 1,2 80 90 C 90 Java Visual Basic 90 2000 Java GUI C

More information

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

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 II 8 2003 11 12 1 6 ( ) 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 Daisuke 8 =>. 73 Daisuke 35 Hiroshi 64 Ichiro 87 Junko

More information

橡Pro PDF

橡Pro PDF 1 void main( ) char c; /* int c; */ int sum=0; while ((c = getchar())!= EOF) if(isdigit(c) ) sum += (c-'0'); printf("%d\n", sum); main()int i,sum=0; for(i=0;i

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

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

Informatics 2015

Informatics 2015 C 計算機の歴史 新旧のソロバン バベッジの階差機関 19C前半 手回し計算機 19C後半 20C後半 スパコン 1960年代 ENIAC (1946) 大型汎用計算機 1950年代 1980年代 電卓 1964 パソコン 1970年代 現在のコンピュータ Input Output Device Central Processing Unit I/O CPU Memory OS (Operating

More information

Microsoft Word - Training8_データ構造とポインタ.docx

Microsoft Word - Training8_データ構造とポインタ.docx Training 8 データ構造とポインタ 株式会社イーシーエス出版事業推進委員会 1 Lesson1 一次元配列 Point 一次元配列を使えるようになろう!! 一次元配列とは 複数の同じ型の変数を 1 つにまとめたものでデータが横 ( 一次元 ) 方向に広がっていく形のものです 複数のデータを一つの配列としてまとめることができます 問題 1 次の配列 array に設定されているデータを答えなさい

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

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

解きながら学ぶC++入門編 !... 38!=... 35 "... 112 " "... 311 " "... 4, 264 #... 371 #define... 126, 371 #endif... 369 #if... 369 #ifndef... 369 #include... 3, 311 #undef... 371 %... 17, 18 %=... 85 &... 222 &... 203 &&... 40 &=...

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

02: 変数と標準入出力

02: 変数と標準入出力 C プログラミング入門 基幹 7 ( 水 5) 12: コマンドライン引数 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/ teachers/w483692/cpr1/ 2016-06-29 1 まとめ : ポインタを使った処理 内容呼び出し元の変数を書き換える文字列を渡す 配列を渡すファイルポインタ複数の値を返す大きな領域を確保する

More information

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n 2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test

More information

数値計算

数値計算 プログラム作成から実行まで 数値計算 垣谷公徳 17 号館 3 階電子メール : kimi@ee.ous.ac.jp Source program hello.c printf("hello\n"); コンパイラ Library libc.a 0011_printf000101001 1101_getc00011100011 1011_scanf1110010100 コンパイル Object module

More information

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

Microsoft PowerPoint - CproNt02.ppt [互換モード] 第 2 章 C プログラムの書き方 CPro:02-01 概要 C プログラムの構成要素は関数 ( プログラム = 関数の集まり ) 関数は, ヘッダと本体からなる 使用する関数は, プログラムの先頭 ( 厳密には, 使用場所より前 ) で型宣言 ( プロトタイプ宣言 ) する 関数は仮引数を用いることができる ( なくてもよい ) 関数には戻り値がある ( なくてもよい void 型 ) コメント

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

Microsoft Word - no15.docx

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

More information

Informatics 2010.key

Informatics 2010.key http://math.sci.hiroshima-u.ac.jp/ ~ryo/lectures/informatics2010/ 1 2 C ATM etc. etc. (Personal Computer) 3 4 Input Output Device Central Processing Unit I/O CPU Memory 5 6 (CPU),,... etc. C, Java, Fortran...

More information

卒 業 研 究 報 告.PDF

卒 業 研 究 報 告.PDF C 13 2 9 1 1-1. 1-2. 2 2-1. 2-2. 2-3. 2-4. 3 3-1. 3-2. 3-3. 3-4. 3-5. 3-5-1. 3-5-2. 3-6. 3-6-1. 3-6-2. 4 5 6 7-1 - 1 1 1-1. 1-2. ++ Lisp Pascal Java Purl HTML Windows - 2-2 2 2-1. 1972 D.M. (Dennis M Ritchie)

More information

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

2008 IIA (program) pro(before)+gram(write) (artificial language) (programming languege) (programming) (machine language) (assembly language) ( ) 2008 IIA 1 1.1 (program) pro(before)+gram(write) (artificial language) (programming languege) (programming) (machine language) (assembly language) () (high-level language) 3 (machine language) (CPU) 0

More information

I J

I J I 065763J 8 7 7 31 jikken/ +----- accumulation_demupa.c +----- accumulation_rain.c +----- frequency_demupa.c +----- frequency_rain.c +----- go.sh +----- graph_maker.sh +----- mesure-ryudai/ 2007/4/1 2007/6/30

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

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

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

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (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

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

第1回 プログラミング演習3 センサーアプリケーション

第1回 プログラミング演習3 センサーアプリケーション C プログラミング - ポインタなんて恐くない! - 藤田悟 fujita_s@hosei.ac.jp 目標 C 言語プログラムとメモリ ポインタの関係を深く理解する C 言語プログラムは メモリを素のまま利用できます これが原因のエラーが多く発生します メモリマップをよく頭にいれて ポインタの動きを理解できれば C 言語もこわくありません 1. ポインタ入門編 ディレクトリの作成と移動 mkdir

More information

r03.dvi

r03.dvi 19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---

More information

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

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

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

(300, 150) 120 getchar() HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgO

(300, 150) 120 getchar() HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgO Handy Graphic for Handy Graphic Version 0.5 2008-06-09 1 Handy Graphic Handy Graphic C Handy Graphic Handy Graphic Mac OS X Handy Graphic HgDisplayer Handy Graphic HgDisplayer 2 Handy Graphic 1 Handy Graphic

More information

ohp03.dvi

ohp03.dvi 19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0

More information

C言語入門

C言語入門 1 C 言語入門 第 11 週 プログラミング言語 Ⅰ( 実習を含む ), 計算機言語 Ⅰ 計算機言語演習 Ⅰ, 情報処理言語 Ⅰ( 実習を含む ) 2 コンパイル時のエラーのパターン 復習 3 gcc のエラーメッセージ 環境変数 LANG を設定すると言語が変わる mintty + bash + GNU C $ LANG=C gcc error1.c error1.c: In function

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

prog-text.dvi

prog-text.dvi (C ) 2008 1 2008.8.7 8 1 E mail : sakkun@yokohama-cu.ac.jp 3 I 13 1 17 1.1.......................... 17 1.1.1.......................... 17 1.1.2 OS................ 17 1.2..............................

More information

pptx

pptx iphone 2010 8 18 C xkozima@myu.ac.jp C Hello, World! Hello World hello.c! printf( Hello, World!\n );! os> ls! hello.c! os> cc hello.c o hello! os> ls! hello!!hello.c! os>./hello! Hello, World!! os>! os>

More information

導入基礎演習.ppt

導入基礎演習.ppt Multi-paradigm Programming Functional Programming Scheme Haskell ML Scala X10 KL1 Prolog Declarative Lang. C Procedural Lang. Java C++ Python Object-oriented Programming / (root) bin home lib 08 09

More information

untitled

untitled II 4 Yacc Lex 2005 : 0 1 Yacc 20 Lex 1 20 traverse 1 %% 2 [0-9]+ { yylval.val = atoi((char*)yytext); return NUM; 3 "+" { return + ; 4 "*" { return * ; 5 "-" { return - ; 6 "/" { return / ; 7 [ \t] { /*

More information

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

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 C () 14 5 23 C () C C C C C 1 Fortran Character*72 name Integer age Real income 3 1 C 1.1 3 7 mandata mandata () name age income mandata () mandata1 1 #include struct mandata char name[51];

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

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

Microsoft Word - C.....u.K...doc C uwêííôöðöõ Ð C ÔÖÐÖÕ ÐÊÉÌÊ C ÔÖÐÖÕÊ C ÔÖÐÖÕÊ Ç Ê Æ ~ if eíè ~ for ÒÑÒ ÌÆÊÉÉÊ ~ switch ÉeÍÈ ~ while ÒÑÒ ÊÍÍÔÖÐÖÕÊ ~ 1 C ÔÖÐÖÕ ÐÊÉÌÊ uê~ ÏÒÏÑ Ð ÓÏÖ CUI Ô ÑÊ ÏÒÏÑ ÔÖÐÖÕÎ d ÈÍÉÇÊ ÆÒ Ö ÒÐÑÒ ÊÔÎÏÖÎ d ÉÇÍÊ

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

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

Microsoft Word - Cプログラミング演習(11) 第 11 回 (7/2) 4. いくつかのトピック (1) ビットごとの演算子 C 言語には, 次のようなビット単位で演算を行う特別な演算子が用意されている & ビットごとの AND ビットごとの OR ^ ビットごとの XOR( 排他的論理和 ) ~ 1 の補数これらの演算子は文字型と整数型で機能し, 浮動小数点数型では使用できない AND, OR, XOR は, それぞれのオペランドの対応するビットを比較して結果を返す

More information

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

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

More information

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

(search: ) [1] ( ) 2 (linear search) (sequential search) 1 2005 11 14 1 1.1 2 1.2 (search:) [1] () 2 (linear search) (sequential search) 1 2.1 2.1.1 List 2-1(p.37) 1 1 13 n

More information

ARM gcc Kunihiko IMAI 2009 1 11 ARM gcc 1 2 2 2 3 3 4 3 4.1................................. 3 4.2............................................ 4 4.3........................................

More information

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

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) * * 2015 2015 07 30 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 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) +

More information

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

問 2 ( 型変換 ) 次のプログラムを実行しても正しい結果が得られない 何が間違いかを指摘し 正しく修正せよ ただし int サイズが 2 バイト long サイズが 4 バイトの処理系での演算を仮定する #include <stdio.h> int main( void ) { int a = 問 1 配列の宣言整数型配列 data1 にデータが初期設定されている この配列 data1 のデータを下図のように 整数型配列 data2 に代入しなさい また data2 の内容を printf( "data2[0] = %d\n", data2[0] ); printf( "data2[5] = %d\n", data2[5] ); を用いて出力しなさい 実行結果 data2[0] = 76

More information

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou 1 1.1 C 2 1 double a[ ][ ]; 1 3x3 0 1 3x3 ( ) 0.240 0.143 0.339 0.191 0.341 0.477 0.412 0.003 0.921 1.2 malloc() 2 double *a[ ]; double 1 malloc() double 1 malloc() free() 3 #include #include

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

K227 Java 2

K227 Java 2 1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html

More information

double float

double float 2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション プログラミング初級 第 13 回 2017 年 7 月 10 日 標準ライブラリ関数 1 標準ライブラリ関数とは 関数には (1) 自分で作る関数 (2) はじめから用意されている関数特に C 言語用用意されているもの : 標準ライブラリ関数 文字列の代入文字列の長さを求める文字列の比較文字列の連結 strcpy strlen strcmp strcat 2 文字列の操作 - 具体例を通して (141

More information

Prog1_15th

Prog1_15th 2012 年 7 月 26 日 ( 木 ) 実施構造体と typedef typedef 宣言によって,struct 構造体タグ名という表記を再定義し, データ型名のように扱うことができる 構文は typedef struct 構造体タグ名 再定義名 ; となり, この場合の構造体変数の宣言は, 再定義名を用いて行うことができる なお, ここでは 構造体タグ名は省略可能である 構造体を指すポインタ

More information

gengo1-2

gengo1-2 変数 プログラム中で 値を格納するには変数 variable を用いる変数は 格納する値の型によって 整数型 文字型 などの型 type をもつ変数を使うには 利用に先立って変数の宣言 declaration をしなければならない 値 変数の値はコンピュータのメモリ上に格納される 具体的にメモリのどの場所に格納されるかは言語処理系が自動的に扱うので プログラマ ( 特に初級者 ) が意識する必要はない

More information

(1 ) scanf(

(1 ) scanf( I 1 C 1 1.1.................................... 1 1.2.................................... 1 1.3.................................... 2 1.4............................ 2 1.4.1.............................

More information

char char 1 signed char unsigned char ( ; single-quote 0x27) ASCII Japan Advanced Institute of Science and Technology

char char 1 signed char unsigned char ( ; single-quote 0x27) ASCII Japan Advanced Institute of Science and Technology I117 3 1 School of Information Science, Japan Advanced Institute of Science and Technology char char 1 signed char -128 127 unsigned char 0 255 ( ; single-quote 0x27) ASCII Japan Advanced Institute of

More information

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-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 C++ 1.1 C C++ C++ C C C++ 1.1.1 C printf() scanf() C++ C hello world printf() 1-1 #include printf( "hello world\n" ); C++ 1-2 std::cout

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

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

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

1 5 13 4 1 41 1 411 1 412 2 413 3 414 3 415 4 42 6 43 LU 7 431 LU 10 432 11 433 LU 11 44 12 441 13 442 13 443 SOR ( ) 14 444 14 445 15 446 16 447 SOR 16 448 16 45 17 4 41 n x 1,, x n a 11 x 1 + a 1n x

More information

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

Microsoft PowerPoint - 11.ppt [互換モード] 第 11 回ポインタの基礎 ( アドレスとポインタ ) 1 今回の目標 C 言語におけるポインタを理解する 変数のアドレスを理解する ポインタ型を理解する アドレス演算子 参照演算子の効果を理解する NULL というアドレスを理解する 複数の関数内で変数のアドレスを表示するプログラムを作成する 2 ポインタ ポインタとは 変数のアドレスを入れる変数である ポインタの型はこれまでのどの型 (char,int,double)

More information