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

Size: px
Start display at page:

Download "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"

Transcription

1 18 C ( ) hello world.c 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.out Hello World [a.out ] % cc hello_world.c -o hello_world [ ( ) ] (K&R 4.1.1) #include "filename" #include <filename> cc -l ( math.h, K&R B4) % cc filename.c -lm 1. temperature1.c ( ) main() 3 { 4 int fahr, celsius; 5 int lower, upper, step; 6 lower = 0; 8 upper = 300; 9 step = 0; 10 fahr = lower; 11 while (fahr <= upper) { 1 celsius = 5 * (fahr-3) / 9; 13 printf("%d\t%d\n", fahr, celsius); 14 fahr = fahr + step; 15 } 16 } [] \n, \t tab, \b, \", \\ 1

2 temperature.c ( ) 5 float fahr, celsius; 6 int lower, upper, step; 8 lower = 0; 9 upper = 300; 10 step = 0; 11 1 fahr = lower; 13 while (fahr <= upper) { 14 celsius = (5.0 /9.0) * (fahr-3) ; 15 printf("%3.0f %6.1f\n", fahr, celsius); 16 fahr = fahr + step; 1 } 18 } [printf ] (K&R p.308, B-) %d 10 %6d 10 6 %f %6f 6 %.f %6.f %o 8 %x 16 %c %s %p %% % 6 [ ] fahr += step; (K&R.10, p.61) sizes.c () main() 3 { 4 printf("char %d\n", sizeof(char)); 5 printf("int %d\n", sizeof(int)); 6 printf("float %d\n", sizeof(float)); printf("double %d\n", sizeof(double)); 8 printf("long double %d\n\n", sizeof(long double)); 9 10 printf("short %d\n", sizeof(short)); 11 printf("long %d\n", sizeof(long)); 1 printf("long long int %d\n", sizeof(long long int)); 13 } [ ] char int short long float double

3 (K&R., p.44) char signed char unsigned char short unsigned short int unsigned int long unsigned long float double long double signed char unsigned char signed short, short int, signed short int unsigned short int signed signed int unsigned signed long, long int, signed long int unsigned long int 1.3 For for.c (For ) 5 int fahr; 6 for (fahr = 0; fahr <= 300; fahr = fahr + 0) printf("%3d %6.1f\n", fahr, (5.0 /9.0) * (fahr-3) ); 8 } do { } while( ); 1.4 symbolic constant.c ( ) 3 #define LOWER 0 4 #define UPPER #define STEP 0 6 main() 8 { 9 int fahr; 10 for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP) 11 printf("%3d %6.1f\n", fahr, (5.0 /9.0) * (fahr-3) ); 1 } 1.5 getchar(), putchar() 3

4 1.5.1 copyfile1.c ( 1 ) 5 int c; 6 c = getchar(); 8 while (c!= EOF){ 9 putchar(c); 10 c = getchar(); 11 } 1 } copyfile.c ( ) c char int EOF : End Of File 5 int c; 6 while ((c = getchar())!= EOF) 8 putchar(c); 9 } 1.5. countletters1.c ( 1 ) 5 long nc; 6 nc = 0; 8 while (getchar()!= EOF) 9 ++nc; 10 printf("%ld\n", nc); 11 } countletters.c ( ) 5 double nc; 6 nc = 0; 8 for (nc = 0; getchar()!= EOF; ++nc) 9 ; 10 printf("%.0f\n", nc); 11 } 4

5 1.5.3 countlines.c ( ) 5 int c, nl; 6 nl = 0; 8 while ((c = getchar())!= EOF) 9 if (c == \n ) 10 ++nl; 11 printf("%d\n", nl); 1 } wc.c () 3 #define IN 1 4 #define OUT main() { 8 int c, nl, nw, nc, state; 9 10 state = OUT; 11 nl = nw = nc = 0; 1 while((c = getchar())!= EOF) { 13 ++nc; 14 if (c == \n ) 15 ++nl; 16 if (c == c == \n c== \t ) 1 state = OUT; 18 else if (state == OUT) { 19 state = IN; 0 ++nw; 1 } } 3 printf("%d %d %d\n", nl, nw, nc); 4 } OUT 空白文字 空白以外の文字 IN 空白文字空白以外の文字 isspace() (K&R B, p.31) 5

6 1.6 countdigits.c () 5 int c, i, nwhite, nother; 6 int ndigit[10]; 8 nwhite = nother = 0; 9 for (i = 0 ; i < 10; ++i) 10 ndigit[i] = 0; 11 1 while((c = getchar())!= EOF) 13 if (c >= 0 && c <= 9 ) 14 ++ndigit[c- 0 ]; 15 else if (c == c == \n c == \t ) 16 ++nwhite; 1 else 18 ++nother; 19 0 printf("digits ="); 1 for (i = 0; i < 10; ++i) printf(" %d", ndigit[i]); 3 printf(", white space = %d, other = %d\n", 4 nwhite, nother); 5 } int ndigit[10] ndigit[0] ndigit[9] c- 0 : c 0 0 c bool.c main() 3 { 4 int result; 5 6 printf("%d\n", 3 <= 5); printf("%d\n",!(3 <= 5)); 8 9 result = 5 == 5; 10 printf("%d\n", result); 11 } K&R p.5, p.54 K&R p.54, if, while, for 6

7 sum.c main() 3 { 4 int d, sum = 0; 5 6 for(;;) { if (scanf("%d", &d)!= 1) 8 break; 9 printf("%d\n", d); 10 sum += d; 11 } 1 printf("sum %d\n", sum); 13 } scanf() ( ) continue (for while ) switch 1. cc -Wall (++ --) cc -Wall (Warning ) warning1.c 1 main() { 3 int i; 4 printf("end\n"); 5 } warning.c 3 int main() 5 printf("end\n"); 6 return 0; } % cc -Wall warning1.c warning1.c:: warning: return type defaults to int warning1.c: In function main : warning1.c:4: warning: implicit declaration of function printf warning1.c:3: warning: unused variable i warning1.c:5: warning: control reaches end of non-void function % cc -Wall warning.c %./a.out end %

8 . (K&R 1., 1.10) function1.c (K&R 1.) int power(int m, int n); 3 4 int main() 5 { 6 int i; for (i = 0; i < 10; ++i) 8 printf("%d %d %d\n", i, power(,i), power(-3,i)); 9 return 0; 10 } 11 int power(int base, int n) 1 { 13 int p; 14 for (p = 1; n > 0; --n) 15 p = p * base; 16 return p; 1 } function.c void power(int m, int n); 3 int result; 4 int main() 5 { 6 int i; extern int result; 8 for (i = 0; i < 10; ++i) 9 { 10 power(, i); 11 printf("%d %d", i, result); 1 power(-3, i); 13 printf(" %d\n", result); 14 } 15 return 0; 16 } 1 void power(int base, int n) 18 { 19 int p; 0 for (p = 1; n > 0; --n) 1 p = p * base; result = p; 3 return ; 4 } int power(int, int); main 0 () exit() void extern 8

9 .3 (K&R 1.9) string.c 3 int main() 5 char word[]="hello"; 6 int length, i; 8 /* char word[] = { H, e, l, l, o, \0 }; 9 char word[6] = { H, e, l, l, o, \0 }; 10 char word[6] = "Hello"; */ 11 1 length = sizeof("hello"); 13 printf("sizeof(\"hello\") = %d\n",length); for (i = 0; i < length; i++) 16 printf("word[%d] = %c (%d)\n", i, word[i], word[i]); 1 18 printf("%s\n", word); 19 return 0; 0 } sizeof("hello") = 6 word[0] = H () word[1] = e (101) word[] = l (108) word[3] = l (108) word[4] = o (111) word[5] = ^@ (0) Hello char word[] = Hello ; word H e l l o 0 \0.4 (K&R.8) increment.c 3 int main() 5 int i; 6 i = 5; while (--i) 8 printf("%d ", i); 9 printf("\n"); i = 5; 1 while (i--) 13 printf("%d ", i); 14 printf("\n"); 15 return 0; 16 }

10 strcat.c (K&R.8, p.59) #define MAXLINE void mystrcat(char s[], char t[]); 5 6 int main() { 8 char former[maxline] = "Hello"; 9 char latter[] = " World!"; printf("%s + %s\n", former, latter); 1 mystrcat(former, latter); 13 printf("%s\n", former); 14 return 0; 15 } 16 1 void mystrcat(char s[], char t[]) 18 { 19 int i, j; 0 1 i = j = 0; while (s[i]!= \0 ) 3 i++; 4 while ((s[i++] = t[j++])!= \0 ) 5 ; 6 } Hello + World! Hello World! 10

11 .5 (K&R 5) pointer1.c (K&R 5.1, p.114) 3 int main() 5 int x =1, y=, z[3] = {, 1, 0}; 6 int *ip; 8 ip = &x; 9 y = *ip; 10 *ip = 0; 11 ip = & z[0]; 1 13 printf(" x = %d, y = %d, z = {%d,%d,%d}\n", 14 x, y, z[0], z[1], z[]); 15 printf(" &x = %p\n", &x); 16 printf(" &y = %p\n", &y); 1 printf(" z = %p\n", z); 18 printf(" &z[0] = %p\n", &z[0]); 19 printf(" &ip = %p\n", &ip); 0 printf(" z[0] = %d\n", z[0]); 1 printf(" ip = %p \n", ip); return 0; 3 } x = 0, y = 1, z = {,1,0} &x = 0xbffffbbc &y = 0xbffffbb8 z = 0xbffffba0 &z[0] = 0xbffffba0 &ip = 0xbffffb9c z[0] = ip = 0xbffffba0 bffffb90 bffffba0 94 a4 98 ip=&z[0]; a8 ac z[0] z[1] z[] z bffffbb0 b4 b8 y 9c ip ip=&x; bc x pointer.c 3 int main() 5 int z[3] = {, 1, 0}; 6 int i, *ip; 8 ip = z; 9 for (i = 0; i < 3; i++) 10 printf("z[%d] = %d, *(z+%d) = %d, %d\n", 11 i, z[i], i, *(z + i), *ip++); 1 return 0; 13 } z[0] =, *(z+0) =, z[1] = 1, *(z+1) = 1, 1 z[] = 0, *(z+) = 0, 0 z[] = {, 1, 0}; z[i] *(z+i) (K&R p.10) *ip++ (*ip)++ *ip++ *(ip++) 11

12 pointer3.c 3 int main() 5 char word[] = "Hello"; 6 char *letter; 8 for (letter = word; *letter; letter++) 9 putchar(*letter); 10 putchar( \n ); 11 return 0; 1 } Hello ( \0 ) 0.6 swap.c (K&R 5.) 3 void swap(int *m, int *n); 4 5 int main() 6 { int a, b; 8 9 a = 10; b = 5; 10 printf("a = %d, b = %d\n", a, b); 11 swap(&a, &b); 1 printf("a = %d, b = %d\n", a, b); 13 return 0; 14 } void swap(int *px, int *py) 1 { 18 int temp; 19 0 temp = *px; 1 *px = *py; *py = temp; 3 } a = 10, b = 5 a = 5, b = 10 a: b: px: py: 1

13 pointer4.c 3 int main(){ 4 char str[] = "test"; 5 int seq[] = {4, 6, 4, 9}; 6 char *c; int *s; 8 c = str; s = seq; 9 10 printf("%c at %p\n", *c, c); c++; 11 printf("%c at %p\n", *c, c); c++; 1 printf("%c at %p\n", *c, c); c++; 13 printf("%c at %p\n\n", *c, c); printf("%1d at %p\n", *s, s); s++; 16 printf("%1d at %p\n", *s, s); s++; 1 printf("%1d at %p\n", *s, s); s++; 18 printf("%1d at %p\n\n", *s, s); 19 0 c = str; printf("%c at %p\n", *c, c); 1 c = str + 1; printf("%c at %p\n", *c, c); c = str + ; printf("%c at %p\n", *c, c); 3 c = str + 3; printf("%c at %p\n\n", *c, c); 4 5 s = seq; printf("%1d at %p\n", *s, s); 6 s = seq + 1; printf("%1d at %p\n", *s, s); s = seq + ; printf("%1d at %p\n", *s, s); 8 s = seq + 3; printf("%1d at %p\n", *s, s); 9 30 return 0; 31 } t at 0xbffffbb0 e at 0xbffffbb1 s at 0xbffffbb t at 0xbffffbb3 ( ) str++ 4 at 0xbffffba0 6 at 0xbffffba4 4 at 0xbffffba8 9 at 0xbffffbac t at 0xbffffbb0 e at 0xbffffbb1 s at 0xbffffbb t at 0xbffffbb3 4 at 0xbffffba0 6 at 0xbffffba4 4 at 0xbffffba8 9 at 0xbffffbac 13

14 pointer5.c 3 int main(){ 4 int seq[], *ip, tmp; 5 6 seq[0] = 5; seq[1] = 10; ip = seq; tmp = 0; printf("ip:%p, tmp:%d, seq[0]:%d, seq[1]:%d\n", 8 ip, tmp, seq[0], seq[1]); 9 10 seq[0] = 5; seq[1] = 10; ip = seq; tmp = 0; 11 tmp = ++*ip; 1 printf("ip:%p, tmp:%d, seq[0]:%d, seq[1]:%d\n", 13 ip, tmp, seq[0], seq[1]); seq[0] = 5; seq[1] = 10; ip = seq; tmp = 0; 16 tmp = *++ip; 1 printf("ip:%p, tmp:%d, seq[0]:%d, seq[1]:%d\n", 18 ip, tmp, seq[0], seq[1]); 19 0 seq[0] = 5; seq[1] = 10; ip = seq; tmp = 0; 1 tmp = *ip++; printf("ip:%p, tmp:%d, seq[0]:%d, seq[1]:%d\n", 3 ip, tmp, seq[0], seq[1]); 4 5 seq[0] = 5; seq[1] = 10; ip = seq; tmp = 0; 6 tmp = *(ip++); printf("ip:%p, tmp:%d, seq[0]:%d, seq[1]:%d\n", 8 ip, tmp, seq[0], seq[1]); 9 return 0; 30 } tmp = (*ip)++; ip:0xbffffbc0, tmp:0, seq[0]:5, seq[1]:10 ip:0xbffffbc0, tmp:6, seq[0]:6, seq[1]:10 ip:0xbffffbc4, tmp:10, seq[0]:5, seq[1]:10 ip:0xbffffbc4, tmp:5, seq[0]:5, seq[1]:10 ip:0xbffffbc4, tmp:5, seq[0]:5, seq[1]:10 tmp = ++*ip tmp = *++ip tmp = *ip++ tmp = *(ip++) 14

[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

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

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

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

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

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

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

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

橡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言語によるアルゴリズムとデータ構造 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

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

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

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

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

P05.ppt

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

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

kiso2-09.key

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

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

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

: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 2018 2018 08 02 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF N N y N x N xy yx : yxxyxy N N x, y N (parse tree) (1) yxyyx (2) xyxyxy (3) yxxyxyy (4) yxxxyxxy N y N x N yx

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

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

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

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

Microsoft Word - Cプログラミング演習(3) 第 3 回 (5/7) 5. ループ ( 繰り返し ) 1 for 文 例題 1-15 正の数 n をキーボードから入力すると,1 から n までの整数の和を出力するプログラムをつくりなさい 出力結果 1-15 2 以上の整数を入力してください! 357 1 + + 357 = 63903 考え方合計を保持する変数を long 型で宣言し, 入力した数値 n までループ処理で累積する 正しい数値が入力されたとき

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

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

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

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

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言語 実践編

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

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

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

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

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

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

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

Ⅰ Report#1 Report#1 printf() /* Program : hello.c Student-ID : 095740C Author UpDate Comment */ #include int main(){ : Yuhi,TOMARI : 2009/04/28(Thu) : Used Easy Function printf() 10 printf("hello,

More information

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

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

More information

gengo1-2

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

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

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

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

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

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

数値計算

数値計算 プログラム作成から実行まで 数値計算 垣谷公徳 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

導入基礎演習.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

卒 業 研 究 報 告.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

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

C 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in

C 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in C 1 / 21 C 2005 A * 1 2 1.1......................................... 2 1.2 *.......................................... 3 2 4 2.1.............................................. 4 2.2..............................................

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

/

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

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

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

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

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

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D 6 2019 5 14 6.1 Minimum C....................... 6 1 6.2....................................... 6 7 6.1 Minimum C Minimum C BNF T okenseq W hite Any Digit ::= 0 1 2... 9. Number ::= Digit Digit. Alphabet

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

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

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

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

Microsoft Word - Cプログラミング演習(8) 第 8 回 (6/11) プログラミングスタイルなど [1] 名前のつけかた グローバル変数にはわかりやすい名前を, ローカル変数には短い名前を 関連性のあるものには関連性のある名前をつけて, 統一しよう 関数には能動的な名前を 名前は的確に 例題 1 次のコードの名前と値の選び方についてコメントせよ? #define TRUE 0? #define FALSE 1?? if ((ch = getchar())

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

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

[ 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: 005 9 7 1 1.1 1 Hello World!! 5 p r i n t f ( H e l l o World!! \ n ) ; 7 return 0 ; 8 } 1: 1 [ ] Hello World!! from Akita National College of Technology. 1 : 5 p r i n t f ( H e l l o World!! \ n ) ;

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

Microsoft Word - 3new.doc

Microsoft Word - 3new.doc プログラミング演習 II 講義資料 3 ポインタ I - ポインタの基礎 1 ポインタとは ポインタとはポインタは, アドレス ( データが格納されている場所 ) を扱うデータ型です つまり, アドレスを通してデータを間接的に処理します ポインタを使用する場合の, 処理の手順は以下のようになります 1 ポインタ変数を宣言する 2 ポインタ変数へアドレスを割り当てる 3 ポインタ変数を用いて処理 (

More information

プログラミング基礎

プログラミング基礎 C プログラミング Ⅰ 条件分岐 if~else if~else 文,switch 文 条件分岐 if~else if~else 文 if~else if~else 文 複数の条件で処理を分ける if~else if~else 文の書式 if( 条件式 1){ 文 1-1; 文 1-2; else if( 条件式 2){ 文 2-1; 文 2-2; else { 文 3-1; 文 3-2; 真条件式

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

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

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

C 言語第 2 回 C 言語の構成要素 ( シラバス 3 4 回目 ) 1 1 予約語 ( 教科書 59 ページの 識別子と予約語 参照 ) コンピュータに実行してもらう命令で C 言語に特有の名前が付いている プログラムの制御構造 : 演算子 : if~else for( ){ } g

C 言語第 2 回 C 言語の構成要素 ( シラバス 3 4 回目 ) 1 1 予約語 ( 教科書 59 ページの 識別子と予約語 参照 ) コンピュータに実行してもらう命令で C 言語に特有の名前が付いている プログラムの制御構造 : 演算子 : if~else for( ){ } g C 言語第 2 回 C 言語の構成要素 ( シラバス 3 4 回目 ) 1 1 予約語 ( 教科書 59 ページの 4 1 2 識別子と予約語 参照 ) コンピュータに実行してもらう命令で C 言語に特有の名前が付いている プログラムの制御構造 : 演算子 : if~else for( ){ } goto sizeof while( ){ break; } do{ } while( ) return

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

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

P03.ppt

P03.ppt (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("");

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

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

Microsoft PowerPoint - CproNt05.ppt [互換モード] 第 5 章 + 第 14 章演算子 CPro:05-01 第 5 章演算子 I 概要 Cには約 40 種類の演算子がある 算術演算子: ( 基本的なもの ) -( 単項 ) * / + - % ++ -- 優先順位( 評価順序 ) の規則 カッコにより優先順位を変えることができる 算術演算子は代入演算子とあわせて複合演算子となる 算術計算では, 型が異なる場合, 暗黙のキャストが行われる ( 最大化

More information

debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology

debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology I117 28 School of Information Science, Japan Advanced Institute of Science and Technology debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology 2008 1-2 1 a) b)

More information

kiso2-03.key

kiso2-03.key 座席指定はありません Linux を起動して下さい 第3回 計算機基礎実習II 2018 のウェブページか ら 以下の課題に自力で取り組んで下さい 計算機基礎実習II 第2回の復習課題(rev02) 第3回の基本課題(base03) 第2回課題の回答例 ex02-2.c include int main { int l int v, s; /* 一辺の長さ */ /* 体積 v

More information

gengo1-12

gengo1-12 外部変数 関数の外で定義される変数を外部変数 ( 大域変数 ) と呼ぶ 外部変数のスコープは広域的 ( プログラム全体 ) 全ての関数で参照可能 int a=10; double x=3.14159; printf( a = %d\n, a); sample(); printf( %f\n, x); void sample(void) printf( %f\n, x); x += 1.0; 外部変数

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

初歩の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

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

(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

BW BW

BW BW Induced Sorting BW 11T2042B 2015 3 23 1 1 1.1................................ 1 1.2................................... 1 2 BW 1 2.1..................................... 2 2.2 BW.................................

More information

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 )

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 ) 1 f(x) a b f(x)dx = n A(x i ) (1) ix [a, b] n i A(x i ) x i 1 f(x) [a, b] n h = (b a)/n y h = (b-a)/n y = f (x) h h a a+h a+2h a+(n-1)h b x 1: 1 x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x

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 C 1 2 1.1........................... 2 1.2........................ 2 1.3 make................................................ 3 1.4....................................... 5 1.4.1 strip................................................

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

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

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

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

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

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

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

+ +

+ + + + 2 1 1 1.1................................ 1 1.2........................... 2 1.3............................. 2 1.4 ( ).................. 2 1.5........................ 3 1.6...................... 3

More information

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

Microsoft PowerPoint - C言語の復習(配布用).ppt [互換モード] if 文 (a と b の大きい方を表示 ) C 言語 Ⅰ の復習 条件判定 (if, 条件式 ) ループ (for[ 二重まで ], while, do) 配列 ( 次元 次元 ) トレース int a, b; printf( 整数 a: ); scanf( %d, &a); printf( 整数 b: ); scanf( %d, &b); //つのif 文で表現する場合間違えやすい どっちに =

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

() / (front end) (back end) (phase) (pass) 1 2

() / (front end) (back end) (phase) (pass) 1 2 1 () () lex http://www.cs.info.mie-u.ac.jp/~toshi/lectures/compiler/ 2018 4 1 () / (front end) (back end) (phase) (pass) 1 2 () () var left, right; fun int main() { left = 0; right = 10; return ((left

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

gengo1-12

gengo1-12 外部変数 関数の外で定義される変数を外部変数 ( 大域変数 ) と呼ぶ 外部変数のスコープは広域的 ( プログラム全体 ) 全ての関数で参照可能 int a=10; double x=3.14159; printf( a = %d\n, a); sample(); printf( %f\n, x); void sample(void) printf( %f\n, x); x += 1.0; 外部変数

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

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

6 6.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave t T = N t N 44.1 khz t = 1 sec j t f j {f 0, f 1, f 2,, f N 1

6 6.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave t T = N t N 44.1 khz t = 1 sec j t f j {f 0, f 1, f 2,, f N 1 6 6.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave t T = t 44.1 khz t = 1 sec 44100 j t f j {f 0, f 1, f 2,, f 1 6.2 T {f 0, f 1, f 2,, f 1 T ft) f j = fj t) j = 0, 1, 2,,

More information

数値計算

数値計算 数値計算 垣谷公徳 17 号館 3 階電子メール : kimi@ee.ous.ac.jp プログラミング言語の一般論 データ型 ( 定数と変数 配列 ) 代入 基本演算 ( 四則演算 ) 入出力 分岐 繰返処理 関数 外部手続き 1 2 入力関数 入出力 getchar, getc, fgetc ; 一文字入力 gets, fgets, fread ; 文字列 ( データ列 ) 入力 scanf,

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