+ +

Size: px
Start display at page:

Download "+ +"

Transcription

1 + +

2 ( ) if switch case

3 while for break include stdio.h stdlib.h string.h math.h main ( ) ( )

4 Dennis Ritchie OS Algol Pascal ( Algol ) Pascal ANSI C (American National Standards Institute) { Pascal begin end int a; Pascal a:integer; FORTRAN INTEGER A b=(a==10)?1:2; a++; t+=dt; if then else if a=10 then b=1 else B=2 a=a+1 t=t+dt char, int, float, double signed, unsigned, long, short

5 if, for while, do, switch, break, continue goto (1) 3 (2) (3) 1.4 ( ) (p ) ( 1.2) 2 ( 1.3) 1 ( 1.4)

6 (1) (2) (3) (4) (3) (5) 1.6 (1) (2) (3) (4) (5) 1.7 cmd Enter )

7 ( ) Enter cd dir ( ) dir ( ) cd.. md dir ( ) ( )dir dir copy file1 file2 file1 file2 del file file [Enter] 1.9 fortran C hogehoge.exe =notepad.exe ).c gcc hogehoge.c -o hogehoge.exe ( hogehoge ) C

8 1 5 #include <stdio.h> int main(void){ /* */ printf("hello, C, hello World!Y=n"); return(0); /* 0 */ hello.c gcc hello.c -o hello.exe hello

9

10 #include <stdio.h> int main(void){ return(0); main C { void 1 stdio.h stdio.h main return 0 void int return C main 0 return

11 2 8 #include <stdio.h> int main(void){ /* */ printf("hello!y=n"); printf(" 100 Y=n"); return(0); (1) (2) C C ; { / / // [ ] (1) n (2) Hello!... (2) (2) Hello! (3) Hello!

12 int ( ) long int float double printf 10 %d #include <stdio.h> int main(void){ /* 12 (10 ) */ printf("%dy=n", 12); /* (10 ) value= 12, 24 */ printf("value= %d, %dy=n", 12, 24); return(0); printf %d printf 2 12 %d 12 ( ) 10 0xaf a f A F 0x 0X

13 ( 1) = 291 ( 2) 16 1f a f 10 a=10, b=11, c=12, d=13, e=14, f= = 31 ( 3) a8 #include <stdio.h> int main(void){ printf("%dy=n", 0x12); / = 18 / printf("%dy=n", 012); / = 10 / printf("%xy=n", 12); / , = c / printf("%oy=n", 12); / 12 = / returen(0); 0x %d %x %o ****************************************************************************** 10 %d e5 3.5e e e

14 2 11 #include <stdio.h> int main(void){ printf("%fy=n", ); printf("%ey=n", ); printf("%fy=n", e+3); printf("%ey=n", e+3); printf("%ey=n", ); printf("%f, %ey=n", , e+3); return(0); printf (%d, %f, %e ) %f (18 ) %e (10 n ) 32 (float) ( ) * / % * (

15 2 12 *, / +, - () #include <stdio.h> int main(void){ printf("1.23e e-1 = %ey=n", 1.23e e-1); printf("1.23e e-1 = %ey=n", 1.23e e-1); printf("1.23e+1 * 2.45e-1 = %ey=n", 1.23e+1 * 2.45e-1); printf("1.23e+1 / 2.45e-1 = %ey=n", 1.23e+1 / 2.45e-1); printf(" = %dy=n", ); printf("10-7 = %dy=n", 10-7); printf("10 * 7 = %dy=n", 10 * 7); printf("10 / 7 = %dy=n", 10 / 7); printf("10 / 7 = %ey=n", 10 / 7); printf("10. / 7 = %ey=n", 10. / 7); printf("1.0e+1 / 7.0e+0 = %ey=n", 1.0e+1 / 7.0e+0); return(0); 10. printf [ 2-1] A G

16 (type) int float 1.23e6 double float char 3.2 p.24 int a; / ; / float b=0.0; / (. ) / double c, d; /, / auto, break, double 3.3 r = 3.5; / r 3.5 / n = n + 1; / n 1 /

17 3 14 j = i++; / j i i 1 / j = ++i; / i 1 j / j = i++; j = i; i = i + 1; j = ++i; i = i + 1; j = i; i--, --i int double float int int double float double double double double float float double float int, double float =

18 scanf #include <stdio.h> int main(void){ /* */ float w, d, h; // (w) (d) (h) float v; // (v) /* */ printf( "w = " ); scanf( "%f", &w ); printf( "d = " ); scanf( "%f", &d ); printf( "h = " ); scanf( "%f", &h ); /* */ v = w * d * h; /* */ printf( " v = %fy=n", v ); return(0); /* 0 */ scanf & scanf float double printf Y=n printf( "w, d, h=" ); scanf( "%d %d %d", &w, &d, &h ); / / [ 2-4]

19 3 16 r (2πr) (πr 2 ) (4πr 3 /3) (4πr 2 ) π #include <stdio.h> #include <math.h> / / int main(void){ double a, b, c; / 3 a, b, c / double s, t; / s = (a + b + c)/2, t: / / a, b, c / printf( "a = " ); scanf( "%lf", &a ); printf( "b = " ); scanf( "%lf", &b ); printf( "c = " ); scanf( "%lf", &c ); / T T = s (s a) (s b) (s c), s = (a + b + c)/2 / s = ( a + b + c ) / 2.0; t = sqrt( s * (s - a) * (s - b) * (s - c)); / / printf( " = %fy=n", t ); return(0); scanf %lf [ 2 5] a = 9, b = 12, c = 15

20 if if 1 2 if ( ) { 1 else { 2 else 1 2 { else if if ( 1){ 1 else if ( 2){ 2 else { n+1

21 if if 1 if (a==2) x=0.0; / a = 2 x 0.0 / else x=1.0; / x = 1.0 / if 2 if (a >= 1) { / a 1 / y=sin(x); else if ( (0 <= a) && (a < 1) ) { / 0 a < 1 / y=cos(x); else { / a < 0 / printf(" Y=n"); if 3 if (a!=0) { / a 0 / printf("game Over!Y=n"); if(a!=0) if(a) if (a==b) if (a=b) [ 4 1] p.44 List3-3 ( 5 )

22 4 19 [ 4 2] 2 B A B A ( 3-1 ) switch case switch case case switch case switch ( ) { case 1: case 2: 1 break; 2 break; case n: default: n break; n+1 switch break switch case if (else if)

23 4 20 [ 4 3] 64 List3-19 (scanf 3 ) [ 4 4] r

24 while while while ( ) { while n 1 n k = n (while ) k=1 #include <stdio.h> int main(void){ int k, n; / / int sum; / / printf( "n = " ); scanf("%d", &n); / / k=1; sum=0; / k sum / while ( k <= n ) { sum = sum + k; / sum+=k; / k = k + 1; / k++; ++k; / printf(" 1 %d =%dy=n", n, sum); return(0);

25 5 22 [ 5 1] while printf k sum n = for while for for ( ; ; ) { for for while ; ; n 1 n k = n (for ) k=1 #include <stdio.h> int main(void){ int k, n; / / int sum; / / printf( "n = " ); scanf("%d", &n); / / sum=0; / sum / for ( k = 1; k <= n; k++ ) { sum = sum + k; / sum+=k; / printf(" 1 %d =%dy=n", n, sum); return(0);

26 5 23 [ 5 2] n for (for ) #include <stdio.h> int main(void){ int i, j, k; for (i=1; i<=9; i++) { for (j=1; j<=9; j++) { k = i * j; printf("%5d", k); printf("y=n"); return(0); for 1 for( n=10; n<=100; n+=10 ) / n+=10 n=n+10 / 2 for( x=0.0; x<=1.0; x+=0.125 ) / / 1 3 for( i=10; i>=1; i-- ) / / for( i=10; i<=1; i-- ) / / [ 5 3] n 1 n ( n 2 ) n for k 2 = 1 n(n + 1)(2n + 1) k=1 6

27 break break break; x ε if ( x < epsilon ) break; break #include <stdio.h> void main(){ int i, n, sum; sum=0; for(i=1; i<=10; i++) { / 10 / printf(" n="); scanf("%d", &n); / / if(n==-1) / n -1 / break; sum+=n; printf("sum=%dy=n", sum); 10-1 [ 5 4] break m m scanf

28 25 6 C , int point1, point2, point3, point4, point5; int point6, point7, point8, point9, point10;.,,., 10 (array).. int point[10];, point 10. point. point[0] = 55; point[1] = 73; point[2] = 69;. point[9] = 81; N 0 N 1. C 0.

29 (74,55,91,48,71,94,83,69), : #include <stdio.h> 2: int main(void){ 3: 4: int point[8]; /* :8 */ 5: int total; /* */ 6: float average; /* ( ) */ 7: int i; /* */ 8: point[0] = 74; 9: point[1] = 55; 10: point[2] = 91; 11: point[3] = 48; /* point */ 12: point[4] = 71; 13: point[5] = 94; 14: point[6] = 83; 15: point[7] = 69; 16: 17: /* */ 18: total = 0; 19: for ( i = 0 ; i < 8 ; i++ ){ 20: total = total + point[i]; 21: 22: 23: /* */ 24: average = (float) total / 8.0e0; 25: 26: printf( "Total Point = %d\n", total); 27: printf( "Average Point = %f\n", average); 28: 29: return(0); 30: 6 2 (x, y) θ 6 2 1: #include <stdio.h> 2: #include <math.h> 3: 4: int main (void){ 5: 6: float x[2]; /* */

30 6 27 7: float y[2]; /* */ 8: float theta, pi; /* */ 9: int i, j; /* */ 10: 11: float matrix[2][2]; /* */ 12: 13: printf(" x "); 14: scanf("%f %f", &x[0], &x[1]); /* scanf & */ 15: 16: printf(" [Deg]"); 17: scanf ("%f", &theta); /* scanf & */ 18: 19: /* */ 20: pi = 4.0e0 * atan(1.0e0); 21: 22: /* */ 23: theta = pi * theta / 180.0e0; 24: 25: /* */ 26: matrix[0][0] = cos (theta); 27: matrix[0][1] = -sin (theta); 28: matrix[1][0] = sin (theta); 29: matrix[1][1] = cos (theta); 30: 31: /* y[i] 0 */ 32: y[0] = 0.0e0; 33: y[1] = 0.0e0; 34: 35: 36: /* x[i] */ 37: for (i = 0; i < 2 ; i++){ 38: for (j = 0; j < 2 ; j++){ 39: y[i] = y[i] + matrix[i][j] * x[j]; 40: 41: 42: 43: /* */ 44: printf(" (%f, %f)\n", x[0], x[1]); 45: printf(" (%f, %f)\n", y[0], y[1]); 46: 47: return(0); 48:

31 , ( ).,. A 11 A 12 A 1M A 12. A A 2M. B 11 B 12 B 1N B 12. B B 2N. C 11 C 12 C 1N = C 12 C 22 C 2N..... (6.1) A L1... A LM B M1... B MN C L1... C LN,. M C ik = A ij B jk = C ik (i = 1, 2,... L, k = 1, 2,... N) (6.2) j=1, 2,. 6 3 A, B A = 0 7 1, B = : #include <stdio.h> 2: int main(void){ 3: 4: int matrixa[3][3] = {3,4,8,0,7,1,4,3,4; 5: int matrixb[3][3] = {1,5,0,0,9,3,3,2,4; 6: int matrixc[3][3] ; 7: int i, j, k; /* */ 8: /* matrixc 0 */ 9: 10: for ( i = 0 ; i < 3 ; i++ ){ 11: for ( j = 0 ; j < 3 ; j++ ){ 12: matrixc[i][j] = 0; 13: 14: 15 16: for ( i = 0 ; i < 3 ; i++ ){ 17: for ( j = 0 ; j < 3 ; j++ ){

32 : for ( k = 0 ; k < 3 ; k++ ){ 19: matrixc[i][k] = matrixc[i][k] 20: +matrixa[i][j]*matrixb[j][k]; 21: 22: 23: 24: printf("c[i, j] = \n"); 25: for ( i = 0 ; i < 3 ; i++ ){ 26: for ( j = 0 ; j < 3 ; j++ ){ 27: printf(" %3d ", matrixc[i][j]); 28: 29: printf("\n"); 30: 31: 32: return(0); 33:,. 4 matrixa, (C 0 ). matrixa[0][0] = 3; matrixa[0][1] = 4; matrixa[0][2] = 8; matrixa[1][0] = 0; matrixa[1][1] = 7; matrixa[1][2] = 1; matrixa[2][0] = 4; matrixa[2][1] = 3; matrixa[2][2] = 4; 6.3 (Char ),.,. kikai 5,. char moji[6]; 1. strcpy kikai.

33 kikai printf 6 4 1: #include <stdio.h> 2: #include <string.h> /* strcpy */ 3: int main(void) 4: { 5: char moji[6]; /* 5 */ 6: strcpy( moji, "kikai" ); 7: printf( "moji = %s\n", moji); 8: 9: return(0); 10: C 0,. kikai moji. moji k i k a i 0 [0] [1] [2] [3] [4] [5] 6.4 A, B A = ( ) 2 4 5, B = No6-HW.c : arai@nuae.nagoya-u.ac.jp : ( ) 17:00 : 08XXXXXXX-No6-HW.c (XXXX ) Subject: 6

34 31 7 C,,,,. C,., 7.1, 2., int i;, i. int 1.,, ( )., i = 256;, i.,. i. a = &i;, &,., a, ( ). 7.2 a int float,.

35 7 32 int *a;, a a int,. 1: #include <stdio.h> 2: int main(void){ 3: int i; /* i */ 4: int *a; /* a */ 5: i = 128; /* i 128 */ 6: a = &i; /* a i */ 7: return(0); 8: 6 a i ( 128 )., a.,. 1: #include <stdio.h> 2: int main(void){ 3: int i; 4: int *a; 5: i = 128; 6: a = &i; 7: printf( "i = %d\n", *a); 8: return(0); 9: 7 7: printf( "i = %d\n", i);., *a *( ), a ( 128).,. 7.3, 10. int a[10];.

36 7 33 a , 10., a[0] p.,. int *p; p = &a[0]; C, p a, p + 1., p + i a[i] &a[i] a i, *(p + i), a[i]., a[0], &a[0] a, , 1: #include <stdio.h> 2: int main(void){ 3: int a[1000]; 4: int i, total; 5: for ( i = 0 ; i < 1000 ; i++ ){ 6: a[i] = i + 1; 7: 8: total = 0; 9: for ( i = 0 ; i < 1000 ; i++ ){ 10 total = total + a[i]; 11: 12: printf( " %d\n", total); 13: return(0); 14

37 N N scanf 1: #include <stdio.h> 2: int main(void){ 3: int a[1000]; 4: int i, total, N; 5: printf("n = "); 6: scanf("%d", &N); 7: if ( N > 1000 ){ 8: printf("n 1000 \n"); 9: exit(0); 10: 11: for ( i = 0 ; i < N ; i++ ){ 12: *(a + i) = i + 1; 13: 14: total = 0; 15: for ( i = 0 ; i < N ; i++ ){ 16: total = total + *(a + i); 17: 18: printf( "1 N %d\n", total); 19: return(0); ,8,9 12, 16 scanf N 1000 a 7.4 ( ) (1000 ) ( )

38 7 35, malloc., 7 1, p = (int*) malloc( 1000*sizeof(int) );, 1000 * sizeof(int) 1000, p., malloc (int*), malloc char* ( ).,, (,, ) : #include <stdio.h> 2: #include <stdlib.h> 3: int main(void){ 4: int *a; 5: int i, total; 6: a = (int*) malloc (1000 * sizeof(int)); 7: if ( a == NULL ){ 8: printf( " \n"); 9: exit(0); 10: 11: for ( i = 0 ; i < 1000 ; i++ ){ 12: a[i] = i + 1; 13: 14: total = 0; 15: for ( i = 0 ; i < 1000 ; i++ ){ 16: total = total + a[i]; 17: 18: printf( " = %d\n", total); 19: return(0); 20: 1, , 16 malloc NULL include a malloc (NULL) *(a + i)

39 scanf ( ) 1: #include <stdio.h> 2: #include <stdlib.h> 3: void main(){ 4: int *p; 5: int a0, d, i, N; 6: printf(" "); 7: scanf("%d", &a0); 8: printf(" "); 9: scanf("%d", &d); 10: printf(" "); 11: scanf("%d", &N); 12: p = (int*) malloc ( N * sizeof(int) ); 13: for ( i = 0 ; i < N ; i++ ){ 14:... 15: scanf

40 37 8 C,., printf scanf C,. 8.1, 1: #include <stdio.h> 2: #include <stdlib.h> 3: int main(void) { 4: printf("hello, world\n"); 5: return(0); 6:, printf (main). ( )., ( ) "hello, world" printf. printf.. 1: #include <stdio.h> 2: #include <stdlib.h> 3: #include <math.h> 4: int main(void){ 5: double a, b; 6: a = e0/3.0e0; 7: b = cos(a); 8: printf("b = %f\n", b); 9: return(0); 10:

41 8 38 a = π/3 (cos) cos. math.h 2, cos printf, printf ( ).,. cos. 8.2 include printf, C, include. 1: #include <stdio.h> 2: #include <stdlib.h> 3: #include <math.h> 3 include, include, stdio.h, stdlib.h math.h,.h. printf stdio.h, stdio.h. stdlib.h exit, cos, math.h stdio.h stdio.h include. stdio.h. close() ctermid() cuserid() fclose() feof() ferror() fileno() fopen() fread() fseek() getc() getchar() gets() lseek() open() pipe() popen() printf() putc() putchar() puts() read() scanf() setbuf() system() tmpfile() tmpnam() ungetc() write() stdlib.h calloc(), malloc(), stdlib.h.

42 8 39 abort() abs() atof() atoi() atol() bsearch() calloc() exit() free() getenv() malloc() mblen() mbstowcs() mbtowc() qsort() rand() realloc() srand() wcstombs() wctomb() string.h string.h. strcat() strncat() strdup() strcmp() strncmp() strcasecmp() strncasecmp() strcpy() strncpy() strlen() strchr() strrchr() strpbrk() strspn() strcspn() strstr() strtok() index() rindex() math.h math.h,. acos() asin() atan() atan2() ceil() cos() cosh() exp() fabs() floor() fmod() frexp() ldexp() log() log10() modf() pow() sin() sinh() sqrt() tan() tanh() 8.3 main (cos) 8 1 (60 ) ( ) 1: #include <stdio.h> 2: #include <stdlib.h> 3: #include <math.h> 4: int main(void){ 5: float theta; /* 60 */ 6: float rad; /* */ 7: float pi = e0; /* */ 8: float get_radian( float ); /* get_radian 9: */ 10: printf(" (60 ) "); 11: scanf("%f", &theta); 12:

43 : /* 60 */ 14: rad = get_radian( theta ); 15: 16: /* */ 17: printf(" %f [rad] \n", rad); 18: printf(" %f [rad] \n", rad/pi); 19: return(0); 20: 21: 22: /* get_radian */ 23: float get_radian ( float a ) { 24: float b; 25: float pi = e0; 26: 27: b = a * pi / 180.0e0; 28: 29: /* */ 30: return ( b ); 31: get radian() ( ) float float 7: float get_radian( float ); 14 ( ) rad cos sin get radian 22 7 ( ) return( ) main C 8.4, a b, change()., (1),.

44 a b. 8 2 (1) ( ) 1: #include <stdio.h> 2: #include <stdlib.h> 3: int main(void){ 4: int a = 3; 5: int b = 8; 6: void change( int, int ); 7: 8: printf("a = %d, b = %d\n", a, b); 9: 10: change ( a, b ); 11: 12: printf(" \n"); 13: printf("a = %d, b = %d\n", a, b); 14: return(0); 15: 16: 17: void change(int x, int y){ 18: int tmp1, tmp2; 19: tmp1 = x; 20: tmp2 = y; 21: x = tmp2; 22: y = tmp1; 23:, main., x, y., main( ),., ( tmp1 tmp2), main., 6 change, void., a b change, change,., ( ),. C,, ( ).,,.,. (1).

45 (2) ( ) 1: #include <stdio.h> 2: #include <stdlib.h> 3: int main(void){ 4: int a = 3;1G 5: int b = 8; 6: void change( int*, int* ); 7: 8: printf("a = %d, b = %d\n", a, b); 9: 10: change ( &a, &b ); 11: 12: printf(" \n"); 13: printf("a = %d, b = %d\n", a, b); 14: return(0); 15: 16: 17: void change(int *x, int *y){ 18: int tmp1, tmp2; 19: tmp1 = *x; 20: tmp2 = *y; 21: *x = tmp2; 22: *y = tmp1; 23:, main change a b &a, &b. change, (*a, *b). ( ),. x, y 16 16: void change(int *x, int *y) x y, *x *y int x y int change 6: void change( int*, int* ); change ( int* &int ) C

46 ,..,. 8 3 N1 N2, ( x) σ ( σ 2 = 1 N (x i x) 2) N. i= : #include <stdio.h> 2: #include <stdlib.h> 3: #include <math.h> 4: int main(void){ 5: int N1, N2; /* */ 6: int i, num, sum; /* num: sum: */ 7: float av, sigma; /* av: sigma: */ 8: int a[1000]; /* */ 9: /* */ 10: void get_sum_av ( int[], int, int*, float*, float* ); 11: printf("n1? "); 12: scanf("%d", &N1); 13: printf("n2? "); 14: scanf("%d", &N2); 15: num = N2 - N1 + 1; 16: if ( num > 1000 ) { 17: printf(" \n"); 18: exit(0); 19: 20: for ( i = 0 ; i < num ; i++ ){ 21: a[i] = N1 + i; 22: 23: /*! */ 24: get_sum_av ( a, num, &sum, &av, &sigma ); 25: printf(" %d\n", sum); 26: printf(" %f\n", av); 27: printf(" %f\n", sigma); 28: return(0); 29: 30: /* */ 31: void get_sum_av (int a[], int num, int *sum, float *av, float *sigma){ 32: int k; 33: float tmp; 34: for ( k = 0, *sum = 0 ; k < num ; k++ ){ 35: *sum = *sum + a[k];

47 : 37: *av = (float)(*sum) / (float)num; 38: for ( k = 0, tmp = 0.0e0 ; k < num ; k++ ){ 39: tmp = tmp + ( (float)a[k] - *av )*( (float)a[k] - *av ); 40: 41: *sigma = sqrt( tmp / (float)num ); 42: return; 43: get sum : void get_sum_av ( int[], int, int*, float*, float* ); void 24: get_sum_av ( int a[], int num, &sum, &av, &sigma ){ 31: void get_sum_av (int a[], int num, int *sum, float *av, float *sigma){ ( ) a ( 7 ) scanf 2. taiseki main. : arai@nuae.nagoya-u.ac.jp : ( ) 17:00 : 08XXXXXX-No8.c ( ) Subject: 8

48 (1)., 1 FILE. FILE *fp; fp (2), fopen,, 2. 1 FILE Structure

49 9 46 fp = fopen("testfile.c","r"); fp = fopen(f_name, "r"); (f_name[]),. ( ),,.,.. r : w : ( ) ( ) fopen., fp. (3) fclose,. fclose(fp); 9.2 fopen NULL., exit., exit stdlib.h,. if((fp = fopen("test.c","r")) == NULL){ printf("file can not open!\n"); exit(1); exit, 0, 0.

50 C fgetc : fgetc, 1. fp ( ) 1 (EOF = End Of File) char int int 2 FILE *fp; int moji; if((fp = fopen("input.dat.c","r")) == NULL){ printf("file can not open! \n"); exit(1); moji = fgetc(fp);... fputc : fputc,, 1. fp c(int ). FILE *fp; int c;... fputc(c, fp); fgets : fgets, char ( ) char EOF 3 MS-Windows PC <CR><LR> ( ) UNIX(Linux) <LF>, Machintosh <CR>

51 9 48 FILE *fp; char s[256];... fgets(s, 256, fp); fgets ( ) NULL fputs : fputs fgets ( ) 1 2, n ( n), n-1. fputs(s, 256, fp); 9 1 1, : #include <stdio.h> 2: #include <stdlib.h> 3: int main(voiod){ 4: int c; 5: char fname[24]; 6: FILE *fp; 7: 8: printf(" \n"); 9: scanf("%s", fname); 10: 11: if((fp = fopen(fname, "r")) == NULL){ 12: printf(" \n"); 13: exit(1); 14: 15: while((c = getc(fp))!= EOF) { 16: putchar(c); 17: 18: fclose(fp); 19: return(0); 20: ( ), getc EOF(-1), while.

52 , : #include <stdio.h> 2: #include <stdlib.h> 3: 4: int main(void){ 5: char fname1[24], fname2[24]; 6: char buf[256]; 7: FILE *fp1, *fp2; 8: 9: printf(" \n"); 10: scanf("%s", fname1); 11: printf(" \n"); 12: scanf("%s", fname2); 13: 14: if((fp1 = fopen(fname1, "r")) == NULL){ 15: printf(" \n"); 16: exit(1); 17: 18: if((fp2 = fopen(fname2, "w")) == NULL){ 19: printf(" \n"); 20: exit(1); 21: 22: 23: while( fgets(buf, 256, fp1)!= NULL ) { 24: fputs(buf, fp2); 25: 26: fclose(fp1); 27: fclose(fp2); 28: return(0); 29: 24 fprintf(fp2, "%s", buf);

53 9 50 fprintf : fprintf,, printf.,. Hello World (fp).,. fprintf(fp, "Hello World\n"); fscanf : fscanf, scanf.. fp,, a. fscanf(fp, "%d", &a); 9 3 Arai 70 Matsumoto 85 Morita : #include <stdio.h> 2: #include <stdlib.h> 3: int main(void){ 4: char name[256]; /* */ 5: char top_name[256]; /* */ 6: int point; /* */ 7: char fname[24]; /* */ 8: FILE *fp; /* */ 9: int max_point = 0; /* */ 10: 11: printf(" \n"); 12: scanf("%s", fname); 13: 14: if((fp = fopen(fname, "r")) == NULL){ 15: printf(" \n"); 16: exit(1); 17: 18:

54 /* while */ 20: while( fscanf(fp, "%s %d", name, &point )!= EOF ){ 21: 22: /* */ 23: if ( point > max_point ){ 24: 25: /*, max_point */ 26: max_point = point; 27: 28: /* top_name */ 29: strcpy( top_name, name ); 30: 31: 32: fclose(fp); 33: printf(" %s %d \n", top_name, max_point); 34: return(0); 35: fscanf EOF while name top name strcpy ( )

55 ( ) 1: #include <stdio.h> 2: #include <stdlib.h> 3: int main(void){ 4: char name[100][256];/* 100 */ 5: int point[100]; /* 100 */ 6: char fname[24]; /* */ 7: FILE *fp; /* */ 8: int index = 0; /* */ 9: int max_point = 0; /* */ 10: int i; /* */ 11: 12: printf(" \n"); 13: scanf("%s", fname); 14 15: if((fp = fopen(fname, "r")) == NULL){ 16: printf(" \n"); 17: exit(1); 18: 19: 20: /* for */ 21: /* 100 */ 22: for ( i = 0; i < 100 ; i++ ){ 23: 24: /* */ 25: if ( fscanf(fp, "%s %d", name[i], &(point[i]) ) == EOF ) 26: break; 27: 28: /* */ 29: if ( point[i] > max_point ){ 30: max_point = point[i]; 31: index = i; 32: 33: 34: fclose(fp); 35: printf(" %s %d \n", name[index], point[index]); 36: return(0); 37:

56 ( ), 2 #include <stdio.h> #include <stdlib.h> int main(void){ float *temp; /* */ char fname1[128]; /* */ char fname2[128]; /* */ FILE *fp1; /* */ FILE *fp2; /* */ int num; /* */ int i; /* */ float time; /* */ float delta_t; /* */ printf(" (1 [ ]) \n"); scanf("%s", fname1); if((fp1 = fopen(fname1, "r")) == NULL){ printf(" \n"); exit(1); printf(" (2 [K]) \n"); scanf("%s", fname2); if((fp2 = fopen(fname2, "w")) == NULL){ printf(" \n"); exit(1); /* (num) (delta_t) */ fscanf(fp1, "%d %f", &num, &delta_t); printf("delta_t = %f\n", delta_t); /* ( ) num */ temp = malloc ( num * sizeof( float ) ); /* temp num (double) */ /* temp[i]! */ /* for */ for ( i = 0; i < num ; i++ ){ /* */ fclose(fp1); return(0);

57 9 54 ( ), : arai@nuae.nagoya-u.ac.jp : ( ) 17:00 : 08XXXXXXX-No9-HW.c (XXXX )

58 55 10 C ( ), f(x) x, (Σ) y k=2 k=3 k=1 k=n a b x Fig.1 f(x) [a, b] [a, b] N x k x k = a + 1 x(2k 1), (k = 1, 2,..., N) (10.1) 2 x = b a N (10.2)

59 10 56 x k y k = f(x k ) (10.3) S k = f(x k ) x (10.4) [a, b] N N S = S k = f(x k ) x (10.5) k=1 k= y = 3x 2 [1, 2] N : #include <stdio.h> 2: #include <stdlib.h> 3: #include <math.h> 4: 5: int main(void){ 6: int k, N; 7: double a, b; /* */ 8: double x; /* */ 9: double dx; /* */ 10: double s; /* */ 11: 12: printf(" \n"); 13: scanf("%d", &N); 14: a = 1.0; 15: b = 2.0; 16: dx = ( b - a ) / (double)n; 17: 18: for( k = 1, s = 0.0 ; k <= N ; k++ ){ 19: x = a + 0.5*dx*(2.0*(double)k - 1.0); 20: s = s * x * x * dx ; 21: 22: printf(" %f\n", s); 23: return(0); 24: N k double

60 y k=2 k=1 k=3 k=n a b x Fig.2 [a, b] N (k ) x L k xr k x L k = a + (k 1) x, (k = 1, 2,..., N) (10.6) x R k = a + k x, (k = 1, 2,..., N) (10.7) y L k = f(x L k ), y R k = f(x R k ) (10.8) (y L k ) (y R k ) ( x) 2 S k = 1 2 {f(xl k ) + f(x R k ) x (10.9) [a, b] N N S = S k = k=1 k=1 1 2 {f(xl k ) + f(x R k ) x (10.10) [a, b] [ ] 1 { N 1 S = f(a) + f(b) + f(x k ) x, x k = k x (10.11) 2 k=1

61 y = 3x 2 [1, 2] N : #include <stdio.h> 2: #include <stdlib.h> 3: #include <math.h> 4: int main(void){ 5: int k, N; 6: double a, b; /* */ 7: double xl, xr; /* */ 8: double yl, yr; /* */ 9: double dx; /* */ 10: double s; /* */ 11: double f( double ); /* f(x) */ 12: printf(" \n"); 13: scanf("%d", &N); 14: a = 1.0; 15: b = 2.0; 16: dx = ( b - a ) / (double)n; 17: for( k = 1, s = 0.0 ; k <= N ; k++ ){ 18: xl = a + dx*((double)k - 1.0); 19: xr = a + dx*(double)k; 20: yl = f(xl); 21: yr = f(xr); 22: s = s * ( yl + yr ) * dx; 23: 24: printf(" %f\n", s); 25: return(0); 26: 27: /* f(x) = 3*x*x */ 28: double f ( double x ){ 29: return ( 3.0 * x * x ); 30: (10) (11) s = 0.5 * ( f(a) + f(b) ) * dx; for( k = 1 ; k < N ; k++ ){ xl = a + (double)k * dx; s = s + f(xl) * dx ;

62 ( ) f( x A ) f( x M ) > 0 f( x B ) f( x M ) < 0 N x B x A x M N+1 Fig.3 2 ax 2 + bx + c = 0 2 y = ax 2 + bx + c y = 0 f(x) = 0 3, y = f(x) [x A, x B ] x, f(x A ) f(x B )., f(x A ) f(x B ) < 0 [x A, x B ] x M, [x A, x M ] [x M, x B ] (y ) [x M, x B ] [x A, x M ] f(x A )f(x M ) > 0, f(x B )f(x M ) < 0 (10.12) f(x A )f(x M ) < 0, f(x B )f(x M ) > 0 (10.13) 2, [x A, x B ] [x A, x B ], x M x B x A x 0 B x 0 A < ϵ (10.14) x 0 A x0 B ε,

63 ln x sin(x) = 0 [1, 5] : #include<stdio.h> 2: #include <stdlib.h> 3: #include<math.h> 4: int main(void){ 5: double a, b, m, dx0; 6: double eps; 7: double f( double ); /* f(x) */ 8: a = 1.0; 9: b = 5.0; 10: dx0 = b - a; 11: eps = 1.0e-8; 12: 13: if ( f(a)*f(b) > 0.0 ) { /* [a, b] */ 14: printf(" [%d, %d] \n", a, b); 15: 16: /* */ 17: while( fabs( (b - a)/dx0 ) > eps ){ 18: m = 0.5 * ( a + b ); 19: printf(" m = %f\n", m); 20: if( f(a)*f(m) < 0.0 ){ /* [a, m] */ 21: b = m; /* [a,m] */ 22: 23: else if( f(b)*f(m) < 0.0 ){ /* [b, m] */ 24: a = m; /* [m,b] */ 25: 26: else { 27: /* */ 28: /* f(m) 0 m */ 29: printf(" (f(m)=0 %f \n", m); 30: exit(0); 31: 32: 33: /* */ 34: printf(" %f \n", m); 35: return(0); 36: 37: /* f(x) */ 38: double f(double x){ 39: return( log(x) - sin(x) ); 40:

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

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

USB 0.6 https://duet.doshisha.ac.jp/info/index.jsp 2 ID TA DUET 24:00 DUET XXX -YY.c ( ) XXX -YY.txt() XXX ID 3 YY ID 5 () #define StudentID 231

USB 0.6 https://duet.doshisha.ac.jp/info/index.jsp 2 ID TA DUET 24:00 DUET XXX -YY.c ( ) XXX -YY.txt() XXX ID 3 YY ID 5 () #define StudentID 231 0 0.1 ANSI-C 0.2 web http://www1.doshisha.ac.jp/ kibuki/programming/resume p.html 0.3 2012 1 9/28 0 [ 01] 2 10/5 1 C 2 3 10/12 10 1 2 [ 02] 4 10/19 3 5 10/26 3 [ 03] 6 11/2 3 [ 04] 7 11/9 8 11/16 4 9 11/30

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

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

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

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

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

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

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

More information

1 4 2 EP) (EP) (EP)

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

More information

数値計算

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

More information

‚æ4›ñ

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

More information

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

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

PowerPoint プレゼンテーション

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

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

超初心者用

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

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

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

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

: 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

: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

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

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

[ 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

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include 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() malloc 2 #include #include #include enum LENGTH = 10 ; int

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

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

Microsoft PowerPoint - CproNt11.ppt [互換モード] 第 11 章入出力関数とライブラリ関数 CPro:11-01 概要 getchar putchar gets puts scanf printf strcat strcmp strcpy strlen atoi atof sprint sscanf 11.1 コンソール入出力関数 11-02 入力 出力 getchar putchar 一文字 gets puts 文字列 ( 一行 ) scanf printf

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

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

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

More information

スライド タイトルなし

スライド タイトルなし ファイル入出力 (2) これまでのおさらい ( 入出力 ) これまでの入出力は 入力 scanf 出力 printf キーボードと画面 ( 端末 ) scanf/printf は 書式つき入出力 フォーマットを指定する 標準入出力を対象とする 何もしなければ 標準入出力は キーボードと画面 ストリームという考え方 ストリーム (stream) = データの列 キーボードから打つ文字列 画面に出力される文字列

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

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

untitled

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

More information

I 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

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

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

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます.  このサンプルページの内容は, 新装版 1 刷発行時のものです. C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/009383 このサンプルページの内容は, 新装版 1 刷発行時のものです. i 2 22 2 13 ( ) 2 (1) ANSI (2) 2 (3) Web http://www.morikita.co.jp/books/mid/009383

More information

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裱£²²ó ¡Ý½ÉÂꣲ¤Î²òÀ⡤±é½¬£²¡Ý

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裱£²²ó  ¡Ý½ÉÂꣲ¤Î²òÀ⡤±é½¬£²¡Ý (2018) 2018 7 5 f(x) [ 1, 1] 3 3 1 3 f(x) dx c i f(x i ) 1 0 i=1 = 5 ) ( ) 3 ( 9 f + 8 5 9 f(0) + 5 3 9 f 5 1 1 + sin(x) θ ( 1 θ dx = tan 1 + sin x 2 π ) + 1 4 1 3 [a, b] f a, b double G3(double (*f)(),

More information

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

Microsoft Word - Cプログラミング演習(9) 第 9 回 (6/18) 3. ファイルとその応用 外部記憶装置に記録されたプログラムやデータを, ファイルと呼ぶ シーケンシャルファイルやランダムファイルへのデータの記録や読み出し, 更新の手順について学習する (1) ファイルとレコードファイル複数の関連したデータを一つに集めたり プログラムを外部記憶装置に保存したものレコードファイルを構成する一塊のデータ ex. 個人カードフィールドレコードを構成する個別の要素

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

ディジタル信号処理

ディジタル信号処理 http://www.cfme.chiba-u.jp/~yama// C 言 語 におけるファイル 入 出 力 テキスト バイナリの 取 り 扱 い ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

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

num2.dvi

num2.dvi kanenko@mbk.nifty.com http://kanenko.a.la9.jp/ 16 32...... h 0 h = ε () 0 ( ) 0 1 IEEE754 (ieee754.c Kerosoft Ltd.!) 1 2 : OS! : WindowsXP ( ) : X Window xcalc.. (,.) C double 10,??? 3 :, ( ) : BASIC,

More information

9 8 7 (x-1.0)*(x-1.0) *(x-1.0) (a) f(a) (b) f(a) Figure 1: f(a) a =1.0 (1) a 1.0 f(1.0)

9 8 7 (x-1.0)*(x-1.0) *(x-1.0) (a) f(a) (b) f(a) Figure 1: f(a) a =1.0 (1) a 1.0 f(1.0) E-mail: takio-kurita@aist.go.jp 1 ( ) CPU ( ) 2 1. a f(a) =(a 1.0) 2 (1) a ( ) 1(a) f(a) a (1) a f(a) a =2(a 1.0) (2) 2 0 a f(a) a =2(a 1.0) = 0 (3) 1 9 8 7 (x-1.0)*(x-1.0) 6 4 2.0*(x-1.0) 6 2 5 4 0 3-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

ファイル入出力

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

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

all.dvi

all.dvi fortran 1996 4 18 2007 6 11 2012 11 12 1 3 1.1..................................... 3 1.2.............................. 3 2 fortran I 5 2.1 write................................ 5 2.2.................................

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

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

ゲームエンジンの構成要素

ゲームエンジンの構成要素 cp-3. 計算 (C プログラムの書き方を, パソコン演習で学ぶシリーズ ) https://www.kkaneko.jp/cc/adp/index.html 金子邦彦 1 本日の内容 例題 1. 自由落下距離四則演算例題 2. 三角形の面積浮動小数の変数, 入力文, 出力文, 代入文例題 3. sin 関数による三角形の面積ライブラリ関数 2 今日の到達目標 プログラムを使って, 自分の思い通りの計算ができるようになる

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

ファイル入出力

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

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

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

untitled

untitled Q 8 1 8.1 (C++) C++ cin cout 5 C++ 16 6 p.63 8.3 #include 7 showbase noshowbase showpoint noshowpoint 8.3 uppercase 16 nouppercase 16 setfill(int) setprecision(int) setw(int) setbase(int) dec

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

2004 2005 2 2 1G01P038-0 1 2 1.1.............................. 2 1.2......................... 2 1.3......................... 3 2 4 2.1............................ 4 2.2....................... 4 2.3.......................

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

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

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

fuga scanf(%lf%*c,&fuga); 改行文字を読み捨てる 10 進数の整数 おまじない取り込んだ値を代入する変数 scanf( %d%*c,&hoge); キーボードから取り込め という命令 1: scanf 1 1: int double scanf %d %lf printf C 2007 5 16 9 1 9 9 if else for 2 hoge scanf("%d%*c",&hoge); ( 1 ) scanf 1 %d 10 2 %*c (p.337) [Enter] &hoge hoge 1 2 10 decimal number d 1 fuga scanf("%lf%*c",&fuga); 改行文字を読み捨てる 10 進数の整数 おまじない取り込んだ値を代入する変数

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

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

slide4.pptx

slide4.pptx ソフトウェア工学入門 第 4 回ライブラリ関数 ライブラリ関数 stdio stdio : 標準入出力ライブラリ カーネルレベルのストリームに API を追加し インタフェースを提供する カーネル fd read(2) write(2) stdio バッファ BUFSIZ プログラム BUFSIZ ごと 小さい単位 バッファ : 一時的にデータを保存しておく場所のことバッファリング : バッファを経由してデータをやり取りすること

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

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

More information

p = 1, 2, cos 2n + p)πj = cos 2nπj 2n + p)πj, sin = sin 2nπj 7.1) f j = a ) 0 + a p + a n+p cos 2nπj p=1 p=0 1 + ) b n+p p=0 sin 2nπj 1 2 a 0 +

p = 1, 2, cos 2n + p)πj = cos 2nπj 2n + p)πj, sin = sin 2nπj 7.1) f j = a ) 0 + a p + a n+p cos 2nπj p=1 p=0 1 + ) b n+p p=0 sin 2nπj 1 2 a 0 + 7 7.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave T > 0 t 44.1 khz t = 1 44100 j t f j {f 0, f 1, f 2,, f 1 = T t 7.2 T {f 0, f 1, f 2,, f 1 T ft) f j = fj t) j = 0, 1,

More information

ディジタル信号処理

ディジタル信号処理 信号処理論 ディジタル画像処理 C 言語におけるファイル入出力 テキスト バイナリの取り扱い ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall o hoge hoge.c..[6]%!! gcc

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

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

Taro-ファイル処理(公開版).jtd ファイル処理 0. 目次 1. はじめに 2. ファイル内容の表示 3. ファイル内容の複写 3. 1 文字単位 3. 2 行単位 4. 書式付き入出力 5. 文字配列への入出力 6. 課題 6. 1 課題 1 ( ファイル圧縮 復元 ) - 1 - 1. はじめに ファイル処理プログラムの形は次のようになる #include main() { FILE *fp1,*fp2; ファイルポインタの宣言

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

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

Microsoft Word - Cプログラミング演習(10) 第 10 回 (6/25) 3. ファイルとその応用 (3) ファイルの更新 シーケンシャルファイルの更新 シーケンシャルファイルでは, 各レコードが可変長で連続して格納されており, その中の特定のレコードを変更することができない そこで一般的には, マスタファイルからデータを取り出し, 更新処理を行ったあとに新マスタファイルに書き込む 注 ) マスタファイル : 主ファイル, 基本ファイルと呼ばれるファイルで内容は比較的固定的であり,

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

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

PowerPoint Presentation

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

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

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

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

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

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

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

演算増幅器

演算増幅器 ファイルこれまでにデータの入力方法として キーボードからの入力を用いてきた 構造体を習った際に実感してもらえたと思うが 入力データ量が多いときにはその作業は大変なものとなり 入力するデータを間違えた場合には最初からやり直しになる そこで今回はこれらの問題を解決するため あらかじめ入力データをテキストエディタなどで編集し ファイルとして保存したものを入力データとして用いる方法を習っていく さらにプログラムで作成したデータをファイルに出力する方法も併せて習っていく

More information

program.dvi

program.dvi 2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation

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

計算機プログラミング

計算機プログラミング プログラミング言語 C 第 8 講 システム標準関数 ( 入出力関数 ) システム標準関数 システムに備え付けの関数 例 ) printf( ); scanf( ); 標準出力関数 標準入力関数 A. 入出力用の関数 高水準入出力関数 高水準言語 (OS に依存しない ) 低水準入出力関数 機械語レベル (OS に依存 ) B. それ以外の関数 引数と関数の型 ( 戻り値 ) に注目しましょう 例

More information

O(N) ( ) log 2 N

O(N) ( ) log 2 N 2005 11 21 1 1.1 2 O(N) () log 2 N 1.2 2 1 List 3-1 List 3-3 List 3-4? 3 3.1 3.1.1 List 2-1(p.70) 1 1 10 1 3.1.2 List 3-1(p.70-71) 1 1 2 1 2 2 1: 1 3 3.1.3 1 List 3-1(p.70-71) 2 #include stdlib.h

More information

2 1 Octave Octave Window M m.m Octave Window 1.2 octave:1> a = 1 a = 1 octave:2> b = 1.23 b = octave:3> c = 3; ; % octave:4> x = pi x =

2 1 Octave Octave Window M m.m Octave Window 1.2 octave:1> a = 1 a = 1 octave:2> b = 1.23 b = octave:3> c = 3; ; % octave:4> x = pi x = 1 1 Octave GNU Octave Matlab John W. Eaton 1992 2.0.16 2.1.35 Octave Matlab gnuplot Matlab Octave MATLAB [1] Octave [1] 2.7 Octave Matlab Octave Octave 2.1.35 2.5 2.0.16 Octave 1.1 Octave octave Octave

More information

コンピュータ概論

コンピュータ概論 4.1 For Check Point 1. For 2. 4.1.1 For (For) For = To Step (Next) 4.1.1 Next 4.1.1 4.1.2 1 i 10 For Next Cells(i,1) Cells(1, 1) Cells(2, 1) Cells(10, 1) 4.1.2 50 1. 2 1 10 3. 0 360 10 sin() 4.1.2 For

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

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

P05.ppt

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

More information

A 30 A A ( ) 2 C C (, machine language) C (C compiler) ( ) Mac Apple Xcode Clan

A 30 A A ( ) 2 C C (, machine language) C (C compiler) ( ) Mac Apple Xcode Clan C 2017 9 29, 30 5 13 http://nalab.mind.meiji.ac.jp/~mk/labo/text/ 1 2 2 C 2 3 4 3.1 C................................... 4 3.2 Hello world........................................ 5 3.3 5...............................

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

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

プログラミング基礎

プログラミング基礎 C プログラミング 演習 アルゴリズム基礎論 演習 第 10 回 今後の予定 12/22( 月 ) 期末試験 (60 分間 ) 場所 :A1611 時間 :16:20~17:20 課題の最終提出締切 :12/19( 金 ) これ以降の新規提出は評価されない 12/22までに最終状況を提示するので, 提出したのに や になってる人は自分の提出内容や提出先を再確認した上で12/26までに問い合わせること

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

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