• 検索結果がありません。

PDLQ (3)1.2 (p.198 ) KRJHKRJH #include <stdio.h&gt

N/A
N/A
Protected

Academic year: 2021

シェア "PDLQ (3)1.2 (p.198 ) KRJHKRJH #include <stdio.h&gt"

Copied!
12
0
0

読み込み中.... (全文を見る)

全文

(1)

C (4) 5E 2004.05.13 1. (11 ) --- 2

1.1 2

1.2 3

1.3 5

1.4 8

1.5 1 9

1.6 10

1.7 11

(2)

1.

1.1

& &

)2575$1

&

&

PDLQ

SULQWI

&

FDOOE\YDOXH )2575$1 68%5287,1(

FDOOE\UHIHUHQFH )2575$1 &

&

SULQWI SULQWI

FDOOE\UHIHUHQFH )2575$1 &

PDLQ

(3)

1.2 (p.198 )

KRJHKRJH #include <stdio.h>

hogehoge( );

main() {

a = hogehoge( );

}

hogehoge( ){

return( );

}

KRJHKRJH

hogehoge( )

LQW GRXEOH

LQW GRXEOH FKDU &

YRLG YRLG

int int ( ) (int )

double double ( ) (double )

char char ( ) (char ) (1 )

char char * ( ) (char * )

void void ( ) (void)

hogehoge( )

H[WHUQ

VWDWLF

(4)

extern static

return( );

return ;

)RUWUDQ

a = hogehoge( );

(5)

1.3 (p.214 )

C (call by value)

1 2

FORTRAN (call by reference)

3

(swapf.f)

swap a b

c --- Main routine --- integer a, b

a=1 b=-1

call swap(a,b) write(6,*)a,b stop

end

c --- Subroutine --- subroutine swap(a,b) integer a, b, c c=a

a=b b=c return end

f77 -o swapf swapf.f

subroutine swap

-1 1

(6)

(swapc.c)

C swap a b

main

#include <stdio.h>

void swap(int a, int b);

/* --- main funtion --- */

main() {

int a, b;

a=1;

b=-1;

swap(a,b);

printf(" %d %d\n",a,b);

}

/* --- swap function --- */

void swap(int a, int b) {

int c;

c=a;

a=b;

b=c;

}

swap main

1 -1

(7)

(swapcp.c)

C swap a b

main

#include <stdio.h>

void swap(int *a, int *b);

/* --- main funtion --- */

main() {

int a, b;

a=1;

b=-1;

swap(&a,&b);

printf(" %d %d\n",a,b);

}

/* --- swap function --- */

void swap(int *a, int *b) {

int c;

c=*a;

*a=*b;

*b=c;

}

swap main

-1 1

(8)

1.4

(noreturn.c) printsin

#include <stdio.h>

#include <math.h>

void printsin(double x);

/* --- main --- */

main() {

char a, b;

double z;

while(1){

printf("next value ? (y/n) ");

scanf("%c%c", &a, &b);

if(a==’y’){

printf("value sin(z) z = ");

scanf("%lf%c", &z, &b);

printsin(z);

}else if(a==’n’){

break;

}else{

printf("input should be y or n\n");

} } }

/* --- printsin function ---*/

void printsin(double x) {

printf("sin(%lf)=%lf\n",x,sin(x));

}

sin math.h

-lm

cc -lm -o noreturn noreturn.c

(9)

1.5 1 (p.222) 1

(onereturn.c)

mysin mysin

3 pow(x,y) xy

#include <stdio.h>

#include <math.h>

double mysin(double theta);

main() {

double x, y, z;

double dpi, pi=4*atan(1);

int i;

dpi = pi/2/100;

printf("=== theta mysin sin ===== \n");

for(i=0; i<=100; i++){

x = dpi*i;

y = mysin(x);

z = sin(x);

printf("%lf %lf %lf \n", x, y, z);

} }

/* ================================================ */

/* taylor expansion of sin function */

/* ================================================ */

double mysin(double theta) {

double yy;

yy = theta-pow(theta,3)/6+pow(theta,5)/120;

return(yy);

}

sin 3

(10)

1.6 (p.223)

return FORTRAN

FORTRAN

p.7 swapcp.c

(fourreturn.c)

4

#include <stdio.h>

#include <math.h>

void sincal(double a1, double a2,

double *y1, double *y2, double *y3, double *y4);

/* ======================================================== */

/* main */

/* ======================================================== */

main() {

double z1, z2, wa, sa, seki, shou;

double pi = 4*atan(1);

z1 = pi/3;

z2 = pi/6;

sincal(z1, z2, &wa, &sa, &seki, &shou);

printf("%lf %lf %lf %lf\n",wa, sa, seki, shou);

}

/* ======================================================== */

/* function sincal */

/* ======================================================== */

void sincal(double a1, double a2,

double *y1, double *y2, double *y3, double *y4) {

double x1, x2;

x1 = sin(a1);

x2 = sin(a2);

*y1 = x1+x2;

*y2 = x1-x2;

*y3 = x1*x2;

*y4 = x1/x2;

}

(11)

1.7

1 1

ƒRƒ FORTRAN

CPU

CR C

(transpose.c)

WUDQVSRVH main

transpose(a);

transpose a[5][5]

transpose transpose(int x[][5])

x[][5]

x[5][5]

x[5][5]

x[100][100][5][5]

hogehoge hogehoge(int x[][100][5][5])

(12)

#include <stdio.h>

void transpose(int x[][5]);

/* --- main ---*/

main() {

int i;

int a[5][5]

={11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45, 51, 52, 53, 54, 55};

for(i=0; i<=4; i++){

printf("%d %d %d %d %d \n",

a[i][0], a[i][1], a[i][2], a[i][3], a[i][4]);

}

transpose(a);

printf("\n");

for(i=0; i<=4; i++){

printf("%d %d %d %d %d \n",

a[i][0], a[i][1], a[i][2], a[i][3], a[i][4]);

} }

/* --- transpose function ---*/

void transpose(int x[][5]) {

int i, j, temp;

for(i=0; i<=3; i++){

for(j=i+1; j<=4; j++){

temp = x[i][j];

x[i][j] = x[j][i];

x[j][i] = temp;

} } }

11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55 11 21 31 41 51 12 22 32 42 52

参照

関連したドキュメント

Although the choice of the state spaces is free in principle, some restrictions appear in Riemann geometry: Because Einstein‘s field equations contain the second derivatives of the

In recent work [23], authors proved local-in-time existence and uniqueness of strong solutions in H s for real s &gt; n/2 + 1 for the ideal Boussinesq equations in R n , n = 2, 3

The proof is quite combinatorial, with the principal aim being to arrange the functions involved into sets to which we can apply the critical maximal inequality of Bourgain, Lemma

A H¨ older regularity result for signed solutions was obtained first by DiBenedetto in [3] for degenerate (p &gt; 2) p-laplacian type equations and then by Chen and DiBenedetto in

&lt; &gt;内は、30cm角 角穴1ヶ所に必要量 セメント:2.5(5)&lt;9&gt;kg以上 砂 :4.5(9)&lt;16&gt;l以上 砂利 :6 (12)&lt;21&gt; l

this to the reader. Now, we come back to the proof of Step 2. Assume by contradiction that V is not empty.. Let u be the minimal solution with the given boundary values and let P be

At the end of the section, we will be in the position to present the main result of this work: a representation of the inverse of T under certain conditions on the H¨older

Views of Kazunogawa Hydroelectric Power Station Dams &lt;Upper dam (Kamihikawa dam)&gt;. &lt;Lower dam