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

Size: px
Start display at page:

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

Transcription

1 C , C C Hello world for for (2) : while if ( ) prog10.c prog11.c prog11-c99.c prog11-c++.c ( ) prog12.c prog12a.c prog12b.c

2 A 30 A A ( ) 2 C C (, machine language) C (C compiler) ( ) Mac Apple Xcode Clang+LLVM cc, gcc Mac GLSC C cglsc cc Clang+LLVM cc, gcc UNIX cc C 1. 1 ( ) ( ) cc -S C cc C prog.c prog.s prog.s a.out 1 2

3 % ls prog.c % cat prog.c int a,b,c,d; a = 1; b = 2; c = 3; d = a * b + c; printf("%d*%d+%d=%d\n", a, b, c, d); % cc -S prog.c % ls prog.c prog.s % cat prog.s ( ) % cc prog.s % ls a.out* prog.c prog.s %./a.out 1*2+3=5 % (macos cc ) prog.s printf() 3

4 prog.s.section TEXT, text,regular,pure_instructions.macosx_version_min 10, 13.globl _main ## -- Begin function main.p2align 4, 0x90 _main: ## BB#0: pushq %rbp Lcfi0:.cfi_def_cfa_offset 16 Lcfi1:.cfi_offset %rbp, -16 movq %rsp, %rbp Lcfi2:.cfi_def_cfa_register %rbp subq $32, %rsp leaq L_.str(%rip), %rdi movl $0, -4(%rbp) movl $1, -8(%rbp) movl $2, -12(%rbp) movl $3, -16(%rbp) movl -8(%rbp), %eax imull -12(%rbp), %eax addl -16(%rbp), %eax movl %eax, -20(%rbp) movl -8(%rbp), %esi movl -12(%rbp), %edx movl -16(%rbp), %ecx movl -20(%rbp), %r8d movb $0, %al callq _printf xorl %ecx, %ecx movl %eax, -24(%rbp) ## 4-byte Spill movl %ecx, %eax addq $32, %rsp popq %rbp retq.cfi_endproc ## -- End function.section TEXT, cstring,cstring_literals L_.str: "%d*%d+%d=%d\n".subsections_via_symbols C C main() ( ) C (/* */ ) 4

5 prog01.c /* prog01.c --- ( ) C */ % cc -o prog01 prog01.c ( cglsc prog01.c) %./prog01 % C ( ) main() 8 C // 1 1 // prog01.c --- ( ) C (main() return ) OS 0 echo $status 0 OS Hello world 2 Hello world prog02.c /* prog02.c --- Hello world */ printf("hello, world.\n"); % cc -o prog02 prog02.c ( cglsc prog02.c) %./prog02 Hello, world. % 2 & 5

6 printf() ( ) " " \n ( \ JIS Y ) printf() printf( ); printf(" \n"); printf() stdio.h #include (stdio=standard input and output, h header file ) /usr/include/stdio.h printf() ( ) prog03.c /* prog03.c (?) */ int a, b; printf(" : "); scanf("%d%d", &a, &b); printf(" %d, %d \n", a, b); printf(" =%d, =%d, =%d, ( )=%d, =%d\n", a + b, a - b, a * b, a / b, a % b); C 6

7 ( 3 ) int ( integer, integral) int ( ) int ; int a; int b, c, d; /* */ ( ) scanf() (scanf() ) ( ) ( ) printf() scanf(), printf() (format) %d (d decimal (10 ) 8 16 ) print() 10 ) printf(" %d\n", ); printf("a=%d, b=%d\n", a, b); printf("a 3 =%d\n", 3 * a); scanf() 10 scanf("%d", & ); scanf("%d", &a); scanf("%d%d", &b, &c); & ( ) scanf() scanf() +, -, *, /, % 3.4 C (floating point numbers) 3 Mac cc ( Clang+LLVM ) 2 31 n n = = long long int ( LL ll LL ll printf() scanf() %lld ) int128 7

8 prog04.c /* prog04.c --- */ double a, b; printf(" : "); scanf("%lf%lf", &a, &b); printf(" %f, %f \n", a, b); printf(" =%f, =%f, =%f, =%f\n", a + b, a - b, a * b, a / b); float, double, long double IEEE float 7, double 16 float , double double ( ) printf() double %f printf("a=%f\n", a); printf("b=%f, c=%f\n", b, c); scanf() double %lf ( ) (l L ) scanf("%lf", &a); scanf("%lf%lf", &b, &c); %lf, %f %e, ( ) %g (n), (m) %n.mf printf("%20.15f\n", a); ( ) 8

9 int double int double double (1) double (2) ( ) int (3) ( ) int int double double long long int a a long long int ( ) 64 double (IEEE754 ) 53 long long int , n n, C (1) (2) (argument) math.h /usr/include/math.h -lm 4 4 libname.a -lname libm.a ( ) -lm 9

10 prog05.c /* prog05.c --- ( ) */ #include <math.h> /* */ double x; printf(" : "); scanf("%lf", &x); /* ( ) */ printf("sqrt(%g) =%g\n", x, sqrt(x)); /* sin */ printf("sin(%g) =%g\n", x, sin(x)); /* e */ printf("exp(%g) =%g\n", x, exp(x)); /* */ printf("log(%g) =%g\n", x, log(x)); /* (10 ) */ printf("log10(%g) =%g\n", x, log10(x)); /* hyperbolic sin) */ printf("sinh(%g) =%g\n", x, sinh(x)); /* (power) */ printf("pow(%g,%g)=%g\n", x, 1.0/3.0, pow(x, 1.0/3.0)); /* Arctan */ printf("atan(%g) =%g\n", x, atan(x)); /* */ printf("fabs(%g) =%g\n", x, fabs(x)); /* (- = Gauss ) */ printf("floor(%g) =%g\n", x, floor(x)); /* */ printf("ceil(%g) =%g\n", x, ceil(x)); % cc -o prog05 prog05.c -lm (-lm l L ) %./prog05 ( ) / 1 1.0/3.0 1/3 0 3 (double)1/(double)3 1.0/ /3 ( )

11 π, e π = (Napier ) e = #include <math.h> double pi, e;... int main()... /* main() pi, e */ pi = 4.0 * atan(1.0); e = exp(1.0); int main() ( ) C C++ 2 ax 2 + bx + c = 0 (a, b, c R, a 0) 3.6 for for() for ( ; ; ) ; for ( ; ; ) 1; 2;... n; n n for (i = 0; i < n; i++) ; ; n = 1, 2,... 2 n, 2 n 11

12 x n := 2 n, y n := 2 n x n, y n x 0 = 1, x n = 2x n 1 (n = 1, 2,... ), y 0 = 1, y n = y n 1 /2 (n = 1, 2,... ) prog06.c /* prog06.c --- for (1) */ int i, n; double x, y; printf(" : "); scanf("%d", &n); x = 1.0; y = 1.0; for (i = 1; i <= n; i++) /* x 2 y 1/2 */ x = 2 * x; y = y / 2; /* %g %f %e */ printf("2 %d =%g, 1/2 %d =%g\n", i, x, i, y); prog06 %./prog06 : =2, 1/2 1 = =4, 1/2 2 = =8, 1/2 3 = =16, 1/2 4 = =32, 1/2 5 = =64, 1/2 6 = =128, 1/2 7 = =256, 1/2 8 = =512, 1/2 9 = =1024, 1/2 10 = =2048, 1/2 11 = =4096, 1/2 12 = =8192, 1/2 13 = =16384, 1/2 14 = e =32768, 1/2 15 = e =65536, 1/2 16 = e =131072, 1/2 17 = e =262144, 1/2 18 =3.8147e =524288, 1/2 19 = e = e+06, 1/2 20 = e-07 % while ()... do... while () 12

13 3.7 for (2) : S n = a 1 + a a n S 0 = 0 S i = S i 1 + a i (i = 1, 2,..., n) S n = n i=1 a i (1) S i s (2) s = 0; (3) s = s + a i ; i = 1, 2,..., n n n 2 prog07.c /* * prog07.c --- for (2) */ int i, n; double s; printf(" : "); scanf("%d", &n); s = 0.0; for (i = 1; i <= n; i++) /* s i s = s + i * i; */ s += i * i; printf(" 1 %d =%g\n", n, s); n 1 S n = k! k=0 : a k = 1/k! while if ( ) while

14 while ( ) ; == ( )!= ( ) < ( ) <= ( ) > ( ) >= ( ) if (1) if ( ) ; (2) if ( ) 1; else 2; prog08a.c /* * prog08a.c */ #include <math.h> double a, b, c, D, sqrtd, re, im, x1, x2; printf("2 a x^2+b x+c=0 \n"); printf("a, b, c: "); scanf("%lf%lf%lf", &a, &b, &c); D = b * b - 4 * a * c; if (D > 0) sqrtd = sqrt(d); x1 = (- b + sqrtd) / (2 * a); x2 = (- b - sqrtd) / (2 * a); printf(" 2 : %20.15g, %20.15g\n", x1, x2); else if (D == 0.0) printf(" ( ): %20.15g\n", - b / (2 * a)); else re = - b / (2 * a); im = sqrt(- D) / (2 * a); printf(" 2 : %20.15g %20.15g \n", re, im); 14

15 prog08.c /* prog08.c --- while if ( ) */ /* * * 1 * ( ) * */ int n; printf(" : "); scanf("%d", &n); while (n!= 1) printf("%d\n", n); if (n % 2 == 0) n = n / 2; else n = 3 * n + 1; printf("%d\n", n); 3.9 ( ) ( ); double square(double); double square(double x); ( )

16 return ; double square(double x) return x * x; sin x (x 0) f(x) := x 1 (x = 0) prog09.c 6 /* prog09.c --- */ #include <math.h> /* f */ double f(double); int i, n; double a; printf(" : "); scanf("%d", &n); a = 1.0; for (i = 0; i < n; i++) a /= 2; printf("1-sin(%g)/%g=%g\n", a, a, 1.0-f(a)); /* f() */ double f(double x) if (x == 0.0) return 1.0; else return sin(x) / x;

17 3.10 input.data output.data 5 prog13.c /* * prog13.c --- fopen(), fclose(), fprintf(), fscanf() * gcc -o prog13 prog13.c */ int a, b, sum; FILE *in, *out; in = fopen("input.data", "r"); /* in NULL */ fscanf(in, "%d%d", &a, &b); fclose(in); sum = a + b; printf("%d %d %d\n", a, b, sum); out = fopen("output.data", "w"); fprintf(out, "%d\n", sum); fclose(out); fopen() 17

18 prog13check.c /* * prog13check.c --- fopen(),fclose(),fprintf(),fscanf() * gcc -o prog13 prog13.c */ int a, b, sum; FILE *in, *out; if ((in = fopen("input.data", "r")) == NULL) fprintf(stderr, "input.data \n"); exit(1); fscanf(in, "%d%d", &a, &b); fclose(in); sum = a + b; printf("%d %d %d\n", a, b, sum); if ((out = fopen("output.data", "w")) == NULL) fprintf(stderr, "output.data \n"); exit(1); fprintf(out, "%d\n", sum); fclose(out); ( ) 1 ( ) malloc() double a[1000]; // 1000 double b[1000]; // Seg fault double *c; // c = malloc(sizeof(double) * 1000); // 1000 if (c == NULL) //... 18

19 prog10.c N /* * prog10.c --- * gcc -o prog10 prog10.c */ #define N (3) /* n x, y */ double inner_product(double x[], double y[], int n) int i; double s; s = 0.0; for (i = 0; i < n; i++) s += x[i] * y[i]; return s; int i; double a[n], b[n]; printf(" %d \n", N); printf(" a \n"); for (i = 0; i < N; i++) printf(" %d =", i + 1); scanf("%lf", &a[i]); printf(" b \n"); for (i = 0; i < N; i++) printf(" %d =", i + 1); scanf("%lf", &b[i]); printf(" =%g\n", inner_product(a, b, N)); prog11.c prog10.c N (C99 C ) malloc() /* * prog11.c --- * gcc -o prog11 prog11.c */ #include <stdlib.h> /* malloc() */ /* n x, y */ 19

20 double inner_product(double *x, double *y, int n) int i; double s; s = 0.0; for (i = 0; i < n; i++) s += x[i] * y[i]; return s; int i, N; double *a, *b; printf(" \n"); printf(" : "); scanf("%d", &N); a = malloc(sizeof(double) * N); b = malloc(sizeof(double) * N); if (a == NULL b == NULL) fprintf(stderr, " \n"); exit(1); printf(" a \n"); for (i = 0; i < N; i++) printf(" %d =", i + 1); scanf("%lf", &a[i]); printf(" b \n"); for (i = 0; i < N; i++) printf(" %d =", i + 1); scanf("%lf", &b[i]); printf(" =%g\n", inner_product(a, b, N)); /* a, b * */ free(a); free(b); prog11-c99.c C C99 (variable length array) ( C11 C++14 ( Mac 8 MB ) ) /* * prog11-c99.c --- * gcc -o prog11-c99 prog11-c99.c */ /* n x, y */ 20

21 double inner_product(double *x, double *y, int n) int i; double s; s = 0.0; for (i = 0; i < n; i++) s += x[i] * y[i]; return s; int i, N; printf(" \n"); printf(" : "); scanf("%d", &N); double a[n], b[n]; printf(" a \n"); for (i = 0; i < N; i++) printf(" %d =", i + 1); scanf("%lf", &a[i]); printf(" b \n"); for (i = 0; i < N; i++) printf(" %d =", i + 1); scanf("%lf", &b[i]); printf(" =%g\n", inner_product(a, b, N)); prog11-c++.c C++ malloc() free() new delete /* * prog11-c++.cpp --- * g++ -o prog11-c++ prog11-c++.cpp */ #include <iostream> #include <cstdlib> using namespace std; /* n x, y */ double inner_product(double *x, double *y, int n) int i; double s; s = 0.0; for (i = 0; i < n; i++) s += x[i] * y[i]; return s; 21

22 int i, N; double *a, *b; cout << " " << endl; cout << " : "; cin >> N; a = new double [N]; b = new double [N]; if (a == NULL b == NULL) cerr << " " << endl; exit(1); cout << " a \n"; for (i = 0; i < N; i++) cout << i+1 << " = "; cin >> a[i]; cout << " b " << endl; for (i = 0; i < N; i++) cout << i+1 << " ="; cin >> b[i]; cout << " =" << inner_product(a, b, N) << endl; /* a, b * */ delete [] a; delete [] b; ( ) ( ) 2 C C99 C Fortran C11 GCC LLVM 2 2 malloc() C++ Eigen 7 C

23 prog12.c 2 /* * prog12.c */ void display(double A[2][2]) int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) printf("%7.2f ", A[i][j]); printf("\n"); int i, j; double a[2][2] = 1,2,3,4; double b[2][2], c[2][2]; /* b */ for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) printf("b[%d][%d]=", i, j); scanf("%lf", &b[i][j]); /* c:=a+b */ for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) c[i][j] = a[i][j] + b[i][j]; /* a,b,c */ printf("a=\n"); display(a); printf("b=\n"); display(b); printf("c=\n"); display(c); prog12 oyabun% gcc prog12.c oyabun%./a.out b[0][0]=4 b[0][1]=3 b[1][0]=2 b[1][1]=1 a= b= c= oyabun% 23

24 prog12a.c 2 /* * prog12a-new.c --- C99 */ /* --- */ void display(int m, int n, double A[m][n]) int i, j; for (i = 0; i < m; i++) for (j = 0; j < n; j++) printf("%7.2f ", A[i][j]); printf("\n"); int i, j, k, m, n; /* */ printf("m= "); scanf("%d", &m); n = m; double a[m][n], b[m][n], c[m][n]; // : m*n /* a */ k = 0; for (i = 0; i < m; i++) for (j = 0; j < n; j++) a[i][j] = k++; /* b */ for (i = 0; i < m; i++) for (j = 0; j < n; j++) printf("b[%d][%d]=", i, j); scanf("%lf", &b[i][j]); /* c:=a+b */ for (i = 0; i < m; i++) for (j = 0; j < n; j++) c[i][j] = a[i][j] + b[i][j]; /* a,b,c */ printf("a=\n"); display(m, n, a); printf("b=\n"); display(m, n, b); printf("c=\n"); display(m, n, c); 24

25 $./prog12a-new m= 2 b[0][0]=1 b[0][1]=2 b[1][0]=3 b[1][1]=4 a= b= c= $ prog12b.c double malloc() /* * prog12b.c --- */ #include <stdlib.h> /* double vector, vector matrix */ typedef double *vector; typedef vector *matrix; /* matrix */ void display(int m, int n, matrix A) int i, j; for (i = 0; i < m; i++) for (j = 0; j < n; j++) printf("%7.2f ", A[i][j]); printf("\n"); /* matrix ( ) */ matrix new_matrix(int m, int n) int i; vector ap; matrix a; if ((a = malloc(sizeof(vector) * m)) == NULL) return NULL; 25

26 if ((ap = malloc(sizeof(double) * (m * n))) == NULL) free(a); return NULL; for (i = 0; i < m; i++) a[i] = ap + i * n; return a; /* matrix */ void free_matrix(matrix a) free(a[0]); free(a); int i, j, m, n; matrix a, b, c; m = 2; n = 2; a = new_matrix(m, n); b = new_matrix(m, n); c = new_matrix(m, n); if (a == NULL b == NULL c == NULL) fprintf(stderr, " \n"); exit(1); /* a */ a[0][0] = 1; a[0][1] = 2; a[1][0] = 3; a[1][1] = 4; /* b */ for (i = 0; i < m; i++) for (j = 0; j < n; j++) printf("b[%d][%d]=", i, j); scanf("%lf", &b[i][j]); /* c:=a+b */ for (i = 0; i < m; i++) for (j = 0; j < n; j++) c[i][j] = a[i][j] + b[i][j]; /* a,b,c */ printf("a=\n"); display(m, n, a); printf("b=\n"); display(m, n, b); printf("c=\n"); display(m, n, c); 4 26

27 4.1 [1] n n 8 [2] a, n a n 9 [3] k, n 1 k, 2 k,, n k 10 [4] a 1 = 1, a n+1 = 3a n + 2 (n 1) 100 (n ) [5] a 0 = 1, a 1 = 1, a n+2 = a n+1 + a n (n 0) ( ) a n n = 1, 2,..., 100 a n a n /a n 1 (n ) [ ] a n /a n 1 ( ) [6] n S 1 (n) := n k=1 1 k, S 2(n) := double [ ] lim n S 2 (n) = π 2 /6 (n, π 2 /6 S 2 (n)) [7] n S n = ) n k=0 1 k! n k=1 1 k 2 (1/k! [8] f : [a, b] R f x (0 x 1/2) f(x) := 1 x (1/2 x 1) 0 ( ) 0.2 x 1.2 [9] ( ) n, x s n (x) := n k=1 ( 1) k+1 (2k 1)! x2k 1 n = 1, 2, 3,, 10 s n (x) (0 x 2π) ( Taylor ) [10] R 3 ( ) 8 n(n + 1)/2 1 n 9 pow() 10 for 27

28 x = r * sin(theta) * cos(phi); y = r * sin(theta) * sin(phi); z = r * cos(theta); ( ) d2p() 11 d2p(x, y, z, &r, &theta, &phi); [11] Euler Runge-Kutta (1) x (t) = x(t), x(0) = 1. x(1) = e (2) x (t) = g γx (t), x(0) = H, x (0) = 0. g > 0, γ 0 ( ) x (t) = g γx (t) 2 (3) d dt ( x y ) ( a = c ) ( b d x y ) (x 0, y 0 ), x(0) = x 0, y(0) = y 0. a, b, c, d [12] cos x x = 0 Newton (f(x) := cos x x f(0) = 1 > 0, f(1) = cos 1 1 < 0 (0, 1) 1 ) 4.2 ( ) [5] n n n a = (a 1, a 2,, a n ) a := max a i i=1,2,,n 3 maxnorm0() 11 Decartes to Polar 28

29 #define N 3 int i; double a[n], maxnorm0(); for (i = 0; i < N; i++) scanf("%lf", &a[i]); printf("maxnorm=%g\n", maxnorm0(a)); double maxnorm0(... ( ) [6] ( ) n maxnorm() #define MAXN 1000 int i, n; double a[maxn], maxnorm(); printf("input n (<= %d): ", MAXN); scanf("%d", &n); if (n > MAXN) exit(1); for (i = 0; i < n; i++) scanf("%lf", &a[i]); printf("maxnorm=%g\n", maxnorm(a, n)); double maxnorm(... maxnorm() ( ) [7] MAXN MAXN n malloc() 29

30 #include <stdlib.h> int i, n; double *a, maxnorm(); printf("input n: "); scanf("%d", &n); a = malloc(n * sizeof(double)); if (a == NULL) fprintf(stderr, " \n"); exit(1); /* OK */ for (i = 0; i < n; i++) scanf("%lf", &a[i]); printf("maxnorm=%g\n", maxnorm(a, n)); double maxnorm(... (C++ C++ ) n addvector(), dotproduct(), norm(), angle() [8] a[0], a[100] a[0], a[1], a[2],, a[100] a[1], a[2],, a[99] maxnorm() A A.1 I(f, a, b) := b a f(x) dx f trapezoidal() 30

31 /* * ex1.c --- 1/x [1,2] */ #include <math.h> typedef double rrfunction(double); rrfunction f; double trapezoidal(rrfunction, double, double, int); int main() int N; double I, T; I = log(2.0); printf(" \n"); printf(" N \n"); for (N = 1; N <= (1 << 16); N *= 2) T = trapezoidal(f, 1.0, 2.0, N); printf("%5d\t%25.18f\t%e\n", N, T, I - T); double trapezoidal(rrfunction f, double a, double b, int N) int j; double h, T; h = (b - a) / N; T = (f(a) + f(b)) / 2; for (j = 1; j < N; j++) T += f(a + j * h); T *= h; return T; double f(double x) return 1 / x; A.2 31

32 /* void vvfunc */ typedef void vvfunc(void); /* vvfunc a */ vvfunc *a = NULL; void f(void) printf("hello\n"); void g(void) printf("bye\n"); int main() a = f; a(); a = g; a(); oyabun% cc -o prog1 prog1.c oyabun%./prog1 Hello Bye oyabun% /* void vvfunc */ typedef void vvfunc(void); void f(void) printf("hello\n"); void g(void) printf("bye\n"); int n = 0; vvfunc *commands[10]; void register_command(vvfunc *F) commands[n++] = F; void all_commands(void) int i; for (i = 0; i < n; i++) commands[i](); int main() register_command(f); register_command(g); all_commands(); 32

33 oyabun% cc -o prog2 prog2.c oyabun%./prog2 Hello Bye oyabun% ( ) /* void vvfunc */ typedef void vvfunc(void); void f(void) printf("hello\n"); void g(void) printf("bye\n"); /* */ int n = 0; vvfunc *commands[10]; char keys[10]; void register_command(vvfunc *F, char c) keys[n] = c; commands[n++] = F; void command(char c) int i; for (i = 0; i < n; i++) if (c == keys[i]) commands[i](); return; /* */ int main() register_command(f, H ); register_command(g, B ); command( H ); command( B ); oyabun% cc -o prog3 prog3.c oyabun%./prog3 Hello Bye oyabun% 33

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

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

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

C , C++ C C++ C++ C cpprefjp - C++ 1 C CUI 2.1 donothing.cpp 1

C , C++ C C++ C++ C cpprefjp - C++ 1 C CUI 2.1 donothing.cpp 1 C++ 2018 7 1, 2018 11 4 http://nalab.mind.meiji.ac.jp/~mk/labo/text/nantoka-c++/ 1 C++ C C++ C++ C cpprefjp - C++ 1 C++17 2 2 CUI 2.1 donothing.cpp 1 /* 2 * donothing.cpp 3 */ 4 5 int main() 6 7 return

More information

新版明解C言語 実践編

新版明解C言語 実践編 2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,

More information

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

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

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

kiso2-09.key

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

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

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

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

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

θ (t) ω cos θ(t) = ( : θ, θ. ( ) ( ) ( 5) l () θ (t) = ω sin θ(t). ω := g l.. () θ (t) θ (t)θ (t) + ω θ (t) sin θ(t) =. [ ] d dt θ (t) ω cos θ(t

θ (t) ω cos θ(t) = ( : θ, θ. ( ) ( ) ( 5) l () θ (t) = ω sin θ(t). ω := g l.. () θ (t) θ (t)θ (t) + ω θ (t) sin θ(t) =. [ ] d dt θ (t) ω cos θ(t 7 8, /3/, 5// http://nalab.mind.meiji.ac.jp/~mk/labo/text/furiko/ l (, simple pendulum) m g mlθ (t) = mg sin θ(t) () θ (t) + ω sin θ(t) =, ω := ( m ) ( θ ) sin θ θ θ (t) + ω θ(t) = ( ) ( ) g l θ(t) = C

More information

joho09.ppt

joho09.ppt s M B e E s: (+ or -) M: B: (=2) e: E: ax 2 + bx + c = 0 y = ax 2 + bx + c x a, b y +/- [a, b] a, b y (a+b) / 2 1-2 1-3 x 1 A a, b y 1. 2. a, b 3. for Loop (b-a)/ 4. y=a*x*x + b*x + c 5. y==0.0 y (y2)

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

C

C C 1 2 1.1........................... 2 1.2........................ 2 1.3 make................................................ 3 1.4....................................... 5 1.4.1 strip................................................

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

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

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

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

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

P05.ppt

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

More information

Cプログラミング1(再) 第2回

Cプログラミング1(再) 第2回 C プログラミング 1( 再 ) 第 2 回 講義では Cプログラミングの基本を学び演習では やや実践的なプログラミングを通して学ぶ 1 前回のレポートから 前回の宿題 数あてゲーム の説明において 次のように書いていたものがいた : これはコンピュータがランダムに設定した数字を人間が当てるゲームである この説明でどこかおかしなところはないだろうか? 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

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

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

: 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

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

More information

数値計算

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

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

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

r1.dvi

r1.dvi 2014 1 2014.4.10 0 / 1 / 2 / 3 Lisp 4 5 ( ) 1 (5 1 ) 5 1 1.1? 0 1 (bit sequence) 5 101 3 11 2 (binary system) 2 1000 8 1 ( ) ( )? ( 1) r1 1000 1001 r2 1002... r3 1: (memory) (address) CPU (instruction)

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

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

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

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

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

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

comment.dvi

comment.dvi ( ) (sample1.c) (sample1.c) 2 2 Nearest Neighbor 1 (2D-class1.dat) 2 (2D-class2.dat) (2D-test.dat) 3 Nearest Neighbor Nearest Neighbor ( 1) 2 1: NN 1 (sample1.c) /* -----------------------------------------------------------------

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

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

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

超初心者用

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

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

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

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double

More information

programmingII2019-v01

programmingII2019-v01 II 2019 2Q A 6/11 6/18 6/25 7/2 7/9 7/16 7/23 B 6/12 6/19 6/24 7/3 7/10 7/17 7/24 x = 0 dv(t) dt = g Z t2 t 1 dv(t) dt dt = Z t2 t 1 gdt g v(t 2 ) = v(t 1 ) + g(t 2 t 1 ) v v(t) x g(t 2 t 1 ) t 1 t 2

More information

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ } C 2: A Pedestrian Approach to the C Programming Language 2 2-1 2.1........................... 2-1 2.1.1.............................. 2-1 2.1.2......... 2-4 2.1.3..................................... 2-6

More information

解きながら学ぶC言語

解きながら学ぶC言語 printf 2-5 37 52 537 52 printf("%d\n", 5 + 37); 5370 source program source file.c ex00.c 0 comment %d d 0 decimal -2 -p.6 3-2 5 37 5 37-22 537 537-22 printf("537%d\n", 5-37); function function call ( )argument,

More information

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

PowerPoint Presentation

PowerPoint Presentation 第 7 回文字列数学関数ファイルの入出力 芝浦工業大学情報工学科青木義満 今回の講義内容 文字列 文字列の配列の扱い 関数への受け渡し 数学関数の利用 平方根, べき乗, 三角関数など ファイル入出力 文字列とは? (p.0) 文字列リテラル 文字 つつ : A, B, 複数の文字の並び= 文字列 puts( ぷろぐらみんぐ入門 ); で囲まれた部分 = 文字列リテラルという 文字列リテラルとナル文字

More information

実際の株価データを用いたオプション料の計算

実際の株価データを用いたオプション料の計算 2002 2 20 1 1 3 2 3 2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 2.1.1 : : : : : : : : : : : : : : : : : : : : 5 2.1.2 : : : : : : : : : : : : : : : : : : : : 6 2.2 : : : : : : : : : :

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

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² – (2018) 11 2018 12 13 2 g v dv x dt = bv x, dv y dt = g bv y (1) b v 0 θ x(t) = v 0 cos θ ( 1 e bt) (2) b y(t) = 1 ( v 0 sin θ + g ) ( 1 e bt) g b b b t (3) 11 ( ) p14 2 1 y 4 t m y > 0 y < 0 t m1 h = 0001

More information

() () (parse tree) ( (( ) * 50) ) ( ( NUM 10 + NUM 30 ) * NUM 50 ) ( * ) ( + ) NUM 50 NUM NUM (abstract syntax tree, AST) ( (( ) * 5

() () (parse tree) ( (( ) * 50) ) ( ( NUM 10 + NUM 30 ) * NUM 50 ) ( * ) ( + ) NUM 50 NUM NUM (abstract syntax tree, AST) ( (( ) * 5 3 lex yacc http://www.cs.info.mie-u.ac.jp/~toshi/lectures/compiler/ 2018 6 1 () () (parse tree) ( ((10 + 30) * 50) ) ( ( NUM 10 + NUM 30 ) * NUM 50 ) ( * ) ( + ) NUM 50 NUM NUM 10 30 (abstract syntax tree,

More information

I 2 tutimura/ I 2 p.1/??

I 2   tutimura/ I 2 p.1/?? I 2 tutimura@mist.i.u-tokyo.ac.jp http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/ 2002 4 25 I 2 p.1/?? / / Makefile I 2 p.2/?? Makefile make GNU make I 2 p.3/?? Makefile L A T E X I 2 p.4/?? core (1) gcc,

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

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) { double

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

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

コンピュータ概論

コンピュータ概論 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

2 [1] 7 5 C 2.1 (kikuchi-fem-mac ) input.dat (cat input.dat type input.dat ))

2 [1] 7 5 C 2.1 (kikuchi-fem-mac ) input.dat (cat input.dat type input.dat )) 2.3 2007 8, 2011 6 21, 2012 5 29 1 (1) (2) (3) 2 Ω Poisson u = f (in Ω), u = 0 (on Γ 1 ), u n = 0 (on Γ 2) f Γ 1, Γ 2 Γ := Ω n Γ Ω (1980) Fortran : kikuchi-fem-mac.tar.gz 1 ( fem, 6701) tar xzf kikuchi-fem-mac.tar.gz

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

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

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

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

More information

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

c-all.dvi

c-all.dvi III(994) (994) from PSL (9947) & (9922) c (99,992,994,996) () () 2 3 4 (2) 2 Euler 22 23 Euler 24 (3) 3 32 33 34 35 Poisson (4) 4 (5) 5 52 ( ) 2 Turbo 2 d 2 y=dx 2 = y y = a sin x + b cos x x = y = Fortran

More information

lexex.dvi

lexex.dvi (2018, c ) http://istksckwanseiacjp/ ishiura/cpl/ 4 41 1 mini-c lexc,, 2 testlexc, lexc mini-c 1 ( ) mini-c ( ) (int, char, if, else, while, return 6 ) ( ) (+, -, *, /, %, &, =, ==,!=, >, >=,

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

y = x 4 y = x 8 3 y = x 4 y = x 3. 4 f(x) = x y = f(x) 4 x =,, 3, 4, 5 5 f(x) f() = f() = 3 f(3) = 3 4 f(4) = 4 *3 S S = f() + f() + f(3) + f(4) () *4

y = x 4 y = x 8 3 y = x 4 y = x 3. 4 f(x) = x y = f(x) 4 x =,, 3, 4, 5 5 f(x) f() = f() = 3 f(3) = 3 4 f(4) = 4 *3 S S = f() + f() + f(3) + f(4) () *4 Simpson H4 BioS. Simpson 3 3 0 x. β α (β α)3 (x α)(x β)dx = () * * x * * ɛ δ y = x 4 y = x 8 3 y = x 4 y = x 3. 4 f(x) = x y = f(x) 4 x =,, 3, 4, 5 5 f(x) f() = f() = 3 f(3) = 3 4 f(4) = 4 *3 S S = f()

More information

スライド 1

スライド 1 数値解析 2019 年度前期第 13 週 [7 月 11 日 ] 静岡大学創造科学技術大学院情報科学専攻工学部機械工学科計測情報講座 三浦憲二郎 講義アウトライン [7 月 11 日 ] 関数近似と補間 最小 2 乗近似による関数近似 ラグランジュ補間 T.Kanai, U.Tokyo 関数近似 p.116 複雑な関数を簡単な関数で近似する 関数近似 閉区間 [a,b] で定義された関数 f(x)

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

1 28 6 12 7 1 7.1...................................... 2 7.1.1............................... 2 7.1.2........................... 2 7.2...................................... 3 7.3...................................

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

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

C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf ("sum=%d n",sum); 2

C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i<=10; i++) sum=sum + i; printf (sum=%d n,sum); 2 アセンブラ (Z80) の例 ORG 100H LD B,10 SUB A LOOP: ADD A,B DEC B JR NZ,LOOP LD (SUM),A HALT ORG 200H SUM: DEFS 1 END 1 C のコード例 (Z80 と同機能 ) int main(void) { int i,sum=0; for (i=1; i

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

: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

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

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

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

第7章 有限要素法のプログラミング

第7章 有限要素法のプログラミング April 3, 2019 1 / 34 7.1 ( ) 2 Poisson 2 / 34 7.2 femfp.c [1] main( ) input( ) assem( ) ecm( ) f( ) solve( ) gs { solve( ) output( ) 3 / 34 7.3 fopen() #include FILE *fopen(char *fname, char

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

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

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

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

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

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

double 2 std::cin, std::cout 1.2 C fopen() fclose() C++ std::fstream 1-3 #include <fstream> std::fstream fout; int a = 123; fout.open( "data.t

double 2 std::cin, std::cout 1.2 C fopen() fclose() C++ std::fstream 1-3 #include <fstream> std::fstream fout; int a = 123; fout.open( data.t C++ 1 C C++ C++ C C C++ 1.1 C printf() scanf() C++ C 1-1 #include int a; scanf( "%d", &a ); printf( "a = %d\n", a ); C++ 1-2 int a; std::cin >> a; std::cout

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

スライド 1

スライド 1 数値解析 平成 24 年度前期第 13 週 [7 月 11 日 ] 静岡大学創造科学技術大学院情報科学専攻工学部機械工学科計測情報講座 三浦憲二郎 講義アウトライン [7 月 11 日 ] 関数近似と補間 最小 2 乗近似による関数近似 ラグランジュ補間 形状処理工学の基礎 点列からの曲線の生成 T.Kanai, U.Tokyo 関数近似 p.116 複雑な関数を簡単な関数で近似する関数近似 閉区間

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

[ 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

2017 p vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = 0 (79) J s flux (67) J (79) J( r, t) = k δf δs s( r,

2017 p vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = 0 (79) J s flux (67) J (79) J( r, t) = k δf δs s( r, 27 p. 47 7 7. vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = (79) J s flux (67) J (79) J( r, t) = k δf δs s( r, t) t = k δf δs (59) TDGL (8) (8) k s t = [ T s s 3 + ξ

More information

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

プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; } Point; 問題 18. 問題 17 の プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; Point; 問題 18. 問題 17 の Point を用いて 2 点の座標を入力するとその 2 点間の距 離を表示するプログラムを作成せよ 平方根は

More information

e.c e.s e.scala /* e.c */ int add(int a, int b) { return a + b; void main() { int a = add(3, 4); printf( %d n, a); ; e.s.text.globl _add _add: pushq %rbp movq %rsp, %rbp movl %edi, -4(%rbp) movl %esi,

More information

Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 初版 1 刷発行時のものです.

Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます.   このサンプルページの内容は, 初版 1 刷発行時のものです. Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/009631 このサンプルページの内容は, 初版 1 刷発行時のものです. Excel URL http://www.morikita.co.jp/books/mid/009631 i Microsoft Windows

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