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 SI a; b #include <stdioh> /* REIDI */ main() int a,b,wa,sa,seki,shou; scanf("%d %d",&a,&b); printf("a=%d, wa=a+b; sa=a-b; seki=a*b; shou=a/b; b=%d\n",a,b); printf("wa=%d, Sa=%d, Seki=%d, Shou=%d\n",wa,sa,seki,shou);
3 main() f g 2 #include <stdioh> 3 int int float char 4 scanf printf 5 = 6 + - * / % 7 8 23 234 234E2 9 abc bc a 2 (b+c)2a x a b c a+b x x 3 x exp #include <stdioh> #include <mathh> /* REIDI 3: Numerical alculation */ main() float x,x2,x3,rx,sx,ex;
4 scanf("%f",&x); x2=x*x; /* square */ x3=x*x*x; /* cube */ rx=sqrt(x); /* square root */ sx=sin(x); /* sine */ ex=exp(x); /* exponential */ printf("%f %f %f %f %f\n",x2, x3, rx, sx, ex); #include <mathh> cos(x) tan(x) log(x)=log e (x) fabs(x) 4 x #include <stdioh> #include <mathh> /* REIDI 4 */ float ube(float x); main() float x,x2,x3,rx,sx,ex; scanf("%f",&x); x2=x*x; x3=ube(x); /* ube */ rx=sqrt(x); sx=sin(x); ex=exp(x); printf("%f %f %f %f %f\n",x2, x3, rx, sx, ex); float ube(float a) /* */ float a3; a3=a*a*a; return(a3);
5 x(y) 2 oat ube(oat x); oat x oat ube 3 x a a3 ube(x) return(a3); 4a: a3 a ube 5 a b max if p24 if ( ) ; ; else ; ; else int max(int x,int y) int max; if (x>y) max = x; else max = y; return(max); g 6 a b 7 a b c
6 p78 8 n! int kaijou(int k) if (k>) return(kaijou(k-)*k); else return(); 9 n n (n 2) (n 4) 2 n n (n 2) (n 4) n nmod2 Euler dy=dx = f(x; y) x = x y = y h y(x + h) y(x)+hf(x; y); (2:) (x n ;y n ) (x n+ x n + h; y n+ )
7 y 6 (x n+ ;y n+ ) # 6 # ## # ## hf(x n ;y n ) # ## - (x n ;y n ) h - x y=y+f(x,y)*h; x=x+h; x=x+h x h x while ( ) ; ; ; 2 /* Rei 2 */ #include <stdioh> main() int i,wa; i=; wa=; while (i<=) wa=wa+i; i=i+;
8 printf("sum of,2,%d=%d\n",i-,wa); while while (i<=) wa+=i; i++; wa+=i wa=wa+i a-=b a=a-b i++ ++i i i=i+ i- - --i i i=i- j=++i j=i++ j=++i j=i++ j=i i n=3 x=n++; x 3 n 4 x=++n; x 4 while while (i<=) wa+=i++; 22 23 dy=dx = x y () Euler x = y = Euler Euler ~y n+ = y n + f(x n ;y n ) h y n+ = y n + f(x n;y n )+f(x n+ ; ~y n+ ) 2 Euler 24 23 h (2:2)
9 Euler y () n = y n + h 2 f () n ; f () n = f(x n ;y n ); y (2) n = y n + h 2 f (2) n ; f (2) n = f(x n + h 2 ;y() n ); y (3) n = y n + hf (3) n ; f (3) n = f(x n + h 2 ;y(2) n ); y n+ = y n + h () (f n +2f (2) n +2f (3) n + f (4) n ); f (4) n = f(x n+ ;y (3) n ) (2:3) 6 dy dx = f y(x; y; z) dz dx = f z(x; y; z) (2:4) Euler while (x<=xmax y=y+fy(x,y,z)*h; z=z+fz(x,y,z)*h; ~y n+ = y n + f y (x n ;y n ;z n ) h ~z n+ = z n + f z (x n ;y n ;z n ) h y n+ = y n + f y(x n ;y n ;z n )+f y (x n+ ; ~y n+ ; ~z n+ ) 2 z n+ = z n + f z(x n ;y n ;z n )+f z (x n+ ; ~y n+ ; ~z n+ ) 2 y2=y+5*(fy(x,y,z)+fy(x+h,y,z))*h; z=z+5*(fz(x,y,z)+fz(x+h,y,z))*h; y=y2; x+=h; h h (2:5) y 2 y y
y d 2 y=dx 2 = f(x; y; y ) = z dz dx = f(x; y; z) dy dx = z (2:6) 25 y = y x = y =;y = x q () (T =x) q = T x (3:) 5 5Js m K E t = q (3:2) x c E = ct c T t = 2 T (3:3) x 2 x = x L u = T T t t = (cl 2 =) u t = 2 u (3:4) x 2 x u t
x x (h) N + u ;u ;u 2 ; ;u N u x = u i+ u i h (3:5) 2 u x 2 = u i+ 2u i + u i h 2 (3:6) u i (t +t) =u i (t)+ t h [u i+(t) 2u 2 i (t)+u i (t)] (3:7) t t x i ; ; 2; ;N t u i = for i =; 2; ;N u = u N = (T = ) u ;u ; ;u N u[] u[i] u[] float u[]; i=; while (i<=n-) u[i]+=r*(u[i+]-2*u[i]+u[i-]); i++; r t=h 2 i= i=n u i while for (i= ; ; i )
2 for (i=; i<=n-; i++) u[i]+=r*(u[i+]-2*u[i]+u[i-]); while i=; (i<=n-) i++; for 3 i 32 t =: :2 :5 r = H 2 x + 2 2 y + 2 =4G (3:8) 2 z2 c T t = 2 T x 2 + H (3:9) u=t 2 u = H (3:) x2 H H T =L 2 x u i+ 2u i + u i = H i h 2 (3:) u = u N = H i - u ;u 2 ; ;u N N - 2 2 2 2 u u 2 u 3 u N = H h 2 u H 2 h 2 H 3 h 2 H N h 2 u N (3:2)
3 r =t=h 2 () t u i (t +t) =u i (t)+ t h [u i+(t) 2u 2 i (t)+u i (t)] (3:7) 2 u=x 2 u(t) u(t+ t) u i (t+t) =u i (t)+ t h f[u i+(t)2u 2 i (t)+u i (t)]+()[u i+ (t+t)2u i (t+t)+u i (t+t)]g (3:8) ( <) ==2 ==2 t +t ru i (t +t)+(2+2r)u i (t +t) ru i+ (t +t) =ru i (t)+(2 2r)u i (t)+ru i+ (t): (3:9) t +t 2+2r r r 2+2r r r 2+2r r r 2+2r r r 2+2r u u u 2 u 3 u N = b b 2 b 3 b N (3:) b i = ru i (t)+(2 2r)u i (t)+ru i+ (t); (3:) u = u N = b =(2 2r)u (t)+ru 2 (t); (3:2a) b N = ru N2 (t)+(22r)u N (t)+2r; (3:2b) t +t u u
4 8>< = x = b (4:) a a 2 a n a 2 a 22 a 2n a n a n2 a nn x = b = a () x + a () 2 x 2 + + a () n x n = b () # a () 2 x + a () 22 x 2 + + a () 2n x n = b () 2 #2 a () 3 x + a () 32 x 2 + + a () 3n x n = b () 3 #3 >: a () n x + a () n2 x 2 + + a () nnx n = b () n #n x # x x 2 x n b b 2 b n (4:2) (4:3) (4:4) (4:5) #2 m 2 = a 2 a (4:6) (a () 22 m 2a () 2 )x 2 + +(a () 2n m 2a () n )x n = b () 2 m 2 b () (4:7) # #3 m 3 = a 3 a (a () 32 m 3a () 2 )x 2 + +(a () 3n m 3a () n )x n = b () 3 m 3 b () 8>< >: a () x + a () 2 x 2 + + a () n x n = b () # a (2) 22 x 2 + + a (2) 2n x n = b (2) 2 #2 a (2) 32 x 2 + + a (2) 3n x n = b (2) 3 #3 2 a (2) n2 x 2 + + a (2) nn x n = b (2) n #n
5 a (2) ij b(2) i ( a (2) ij = a () ij m i a () j i; j =2; 3; ;n b (2) i = b () i m i b () i =2; 3; ;n #3' x 2 x i for (k=; k <= n-; k++) d[k]=a[k][k]; for (i=k+; i<=n; i++) m[i][k]=a[i][k]/d[k]; for (j=k+; j<=n; j++) a[i][j]=a[i][j]-m[i][k]*a[k][j]; b[i]=b[i]-m[i][k]*b[k]; U = (4:9) U x = b (4:) a () a () 2 a () n b = a (2) 22 a (2) 2n b () b (2) 2 b (n) n a (n) nn (4:) (4:) U n n x n =(b (n) n n 2 x n2 =(b (n2) n2 x n = b (n) n =a(n) nn (4:3) a (n) n n x n)=a (n) n n (4:4) a (n2) n2 n x n a (n2) n2 n x n)=a (n2) n2 n2 (4:5) x i
6 x[n]=b[n]/a[n][n]; for (i=n-; i>=; i--) x[i]=b[i]; for (j=i+; j<=n; j++) x[i]=x[i]-a[i][j]*x[j]; x[i]=x[i]/a[i][i]; x H = [a; b] N I = Z b a f(x)dx; (5:) h =(b a)=n (5:2) I " # N X I N = h 2 f(a)+ f(a + nh)+ 2 f(b) n= (5:3) N N N = N =2,N =4, I N I 2N I (57) I N I 2N N = I =[f(a)+f(b)] b a 2 N (h )I 2N J N = h NX n= f a +(n 2 )h (5:4) (5:5)
7 I N h =(b a)=n I 2N = I N + J N 2 I 2N ji N I 2N j < ( 6 ) Z 2 I = dx(= ) (5:7) +x2 (5:6) f(x) Z I = f(x)dx (5:8) I(h) =h X n= f(nh) (5:9) f(nh) sin x exp x2 2 x f(nh) f((n +)h),f((n +)h) I(h) h h ji(h) I(h=2)j Z I =2 exp x2 2 dx(= p 2) (5:) a b c d e f g a ;a 2 ;a 3 ; a[] a[i] a[i] i=3 a[3] int a[]; float b[]; f(nh)
8 a[] a[] a[2] a[99] b[] b[] b[2] b[9] c:testdat 5 88 45 6 9 c:testdat main() FILE *inf; inf inf = fopen("c:testdat", "r"); c:testdat inf r read w a fscanf(inf,&a[i]) a[i] scanf( inf fscanf(inf, fprintf(outf, saidai_chi=; for (i= ;i<= n ; i++) if (a[i]> saidai_chi) end; saidaichi=a[i];
9 () (,) x- 639 y- 399 (2) #include #include <graphicsh> main() gd = DETET; initgraph(&gd, &gm, "b:\\turbo_c\\bgi"); gd gm int (3) (x[];y[]); (x[];y[]); moveto(fx(x[]), Fy(y[])); for (i:=; i<=n; ++i) lineto(fx(x[i]), Fy(y[i])); moveto(int x, int y) (x,y) lineto(int x, int y) (x,y) Fx(x) x 639 Fy(y) y 399 int Fx(x:real) return(639*x); x=( ) Fx=( 639) (4) closegraph; y printf("do you erase this graph?"); scanf("%c",&y); if (y=='y') then closegraph;
2 y char y; DOS :\> g cls :\> hardcopy [copy] [cntl]+[copy] [graph]+[copy]