$ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a

Size: px
Start display at page:

Download "$ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a"

Transcription

1 $ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a

2 $ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filename> less $ man <cmdname> <cmdname> $ mkdir <dirname> <dirname>

3 nrps ~ nrps ~/nrps $ cd ~/nrps nrps /* This is my first C program. */ #include<stdio.h> #define MYNAME "abcdefg" int main() { printf("hello World!!\n"); printf("my name is %s.\n",myname); return(0); }

4 hello.c.c ~/nrps hello.c /* This is my first C program. */ #include<stdio.h> #define MYNAME "abcdefg" int main() { printf("hello World!!\n"); printf("my name is %s.\n",myname); return(0); } hello.c hello.c ~/nrps $ cd ~/nrps nrps $ ls-a $ gcc hello.c -o hello.out -lm

5 hello.c hello.out hello.out aaa.out aaa.out $ ls hello.out $./hello.out gcc... c ~/nrps $ cd ~/nrps $ chmod +x c $ cd ~/nrps $./c hello hello.c hello.out hello.c ~/nrps ~/nrps $ cd~/nrps

6 cd $ ls -a $ rm -r <file name> $ ls -a

7 io_sample.c #include <stdio.h> int main() { int a, b; int c; printf("input:\n"); printf("a="); scanf("%d",&a); printf("b="); scanf("%d",&b); printf("a=%d,b=%d",a,b); c = a+b; printf("c = a + b = %d + %d = %d", a, b, c); if( c < 0 ){ printf("%d is negative.\n",c); }else if(c > 0){ printf("%d is positive.\n",c); }else{ printf("%d is zero.\n"); } } return 0; a b c c

8 \n

9 int double float char long short int char double float char char.c #include <stdio.h> int main() { char a,b,c; a = 'x'; b = '1'; c = '%'; printf("%c %c %c\n",a,b,c); printf("%d %d %d\n",a,b,c); } return(0); char_tab.c #include <stdio.h> int main() {

10 char a,b,c; a = 'x'; b = '1'; c = '%'; printf("%c\t%c\t%c\n",a,b,c); printf("%d\t%d\t%d\n",a,b,c); } return(0); printf %d %c char printf %f %e %g % variable.c

11 #include <stdio.h> int main(void) { int i,j; double f,g,h,k; i = 1.5; j = 2/3; f = 2/3; g = 2/(double)3; h = 2/3.0; k = 2.0/3; } printf("int i = 1.5 = %d\n",i); printf("int j = 2/3 = %d\n",j); printf("double f = 2/3 = %f\n",f); printf("double g = 2/(double)3 = %f\n",g); printf("double h = 2/3.0 = %f\n", h); printf("double k = 2.0/3 = %f\n", k); return 0;

12 { } #include.c ; #include <stdio.h> int main() { printf("hello World!\n"); return(0); } #include <stdio.h> int main(){printf("hello World!\n");return(0);} main()

13 #include <stdio.h> int mai n(){printf("hello World!\n");return(0);} ; : {} () [] <> #include '' "" / % { } _ _

14 + a = b+c; b c a - a = b-c; b c a * a = b*c; b c a / a = b/c; b c a % a = b%c; b c a ++ a++; ++a; a = a + 1; -- a--; --a; a = a - 1; - b = -a; = a = b += a += b; a = a + b; -= a -= b; a = a - b; *= a *= b; a = a*b; /= a /= b; a = a/b; %= a %= b; a = a%b; > < >= <= ==!=

15 &&! a = (b > c); c b a a a = ( b!= c); b c a a a = (b > c) && (c < d); b>c c<d a a = (b > c) (c < d); b>c c<d a a =!(b > c); b>c a if for while 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 int num,i; 7 8 for(i=0;i<4;i++){ 9 num = rand()%2000; if(num < 100){ 12 printf("%d < 100\n", num); 13 }else if(num > 1000){ 14 printf("%d > 1000\n", num);

16 15 }else{ 16 printf("100 <= %d <= 1000\n",num); 17 } if(num < 100)printf("The num is smaller than 100\n"); } i=0; 24 while(i < 5){ 25 num = rand()%2000; 26 printf("num = %d\n",num); 27 i++; 28 } do{ 31 num = rand()%2000; 32 printf("in do_while, num = %d\n",num); 33 i--; 34 }while(i>0); return(0); 37 } 38

17

18 janken_1.c 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #define GU "\n nnnn\ncuuuu\n" 5 #define TYOKI "\n n n\n //\n N\n \\ /\n" 6 #define PA "\nnnnn\n /\\\n / /\n\\ /\n" 7 8 int main() 9 { 10 char man, pc; 11 char *man_no_te, *pc_no_te; 12 time_t now; 13 char *time_char; 14 char ctmp[10]; 15 int hour, min, sec, tmp; 16 unsigned seed; printf("let's do JAN-KEN with me!!!!!\n"); 19 printf("jan-ken-pon \ngu: %s\n TYOKI: %s\n PAH: %s\n\n", GU, TYOKI, PA); 20 printf("input your choice from G, T and P (for GU, TYOKI, PAH)\n"); 21 printf("-->"); 22 scanf("%c", &man); if(man == 'g'){ 25 man='g'; 26 man_no_te = GU; 27 }else if(man == 'G'){ 28 man_no_te = GU; 29 }else if(man == 't'){ 30 man='t'; 31 man_no_te = TYOKI;

19 32 }else if(man == 'T'){ 33 man_no_te = TYOKI; 34 }else if(man == 'p'){ 35 man = 'P'; 36 man_no_te = PA; 37 }else if(man == 'P'){ 38 man_no_te = PA; 39 } /* Initialization of random number */ 42 time(&now); 43 time_char = ctime(&now); 44 sscanf(time_char,"%s %s %d %d:%d:%d %d\n", ctmp, ctmp, &tmp, 45 &hour, &min, &sec, &tmp); 46 printf("%d:%d:%d\n", hour, min, sec); 47 seed = hour+min+sec; 48 srand(seed); 49 /****/ pc = rand()%3; 52 if(pc == 0){ 53 pc = 'G'; 54 pc_no_te = GU; 55 } 56 if(pc == 1){ 57 pc = 'T'; 58 pc_no_te = TYOKI; 59 } 60 if(pc == 2){ 61 pc = 'P'; 62 pc_no_te = PA; 63 } printf("you:\n %s \ni CPU:\n %s \n", man_no_te, pc_no_te);

20 66 if((man == 'G' && pc == 'P') (man == 'T' && pc == 'G') 67 (man == 'P' && pc == 'T')){ 68 printf("i CPU won.\n"); 69 }else if(man == pc){ 70 printf("draw.\n"); 71 }else{ 72 printf("you won.\n"); 73 } return(0); 76 }

21 if switch int scanf int %d char c short %hd long %ld float %f double %lf &&! ifswitch while for do while for_if.c 1 #include <stdio.h> 2 3 int main() 4 { 5 int j; 6 7 for(j=0;j<6;j++){ /* j++ j = j+1, j-- j = j-1 */ 8 if(j%2 == 0){ 9 printf("j = %d\n", j); 10 }else{ 11 printf("-----\n"); 12 } 13 }

22 14 15 printf("*****\n*****\n"); for(j=0;j<6;j++){ 18 if(j/2 == 1){ 19 printf("j = %d\n", j); 20 }else{ 21 printf("-----\n"); 22 } 23 } return(0); 26 } #include <stdio.h> int main() { int i; int wa; wa = 0; for(i=0;i<=10;i++){ wa += i; } printf(":%d\n",wa); } return(0); while

23 #include <stdio.h> int even(int j) { if(j%2 == 0){ return(1); }else{ return(0); } } int main() { int j; printf("\n"); for(j=0;j<10;j++){ printf("%d is ",j); if(even(j)){ printf("even.\n"); }else{ printf("odd.\n"); } } return(0); } #include <stdio.h>

24 int even(int a); int main() { int j; printf("\n"); for(j=0;j<10;j++){ printf("%d is ",j); if(even(j)){ printf("even.\n"); }else{ printf("odd.\n"); } } return(0); } int even(int j) { if(j%2 == 0){ return(1); }else{ return(0); } } #include <stdio.h> int main() {

25 double a, b; a = 1.0; b = 2.0; } printf("%f\n", waru(a,b)); return(0); double tasu(double x, double y) { return(x+y); }

26 int x; x & &x int *p; p *p #include <stdio.h> int main() { int x; int *p; p = &x; x = 1; printf("x = %d\n", x); printf("address of x = %p\n", &x); printf("p = %p\n", p); *p = 2; printf("after *p = 2, \n"); printf("x = %d\n", x); printf("address of x = %p\n", &x); printf("p = %p\n", p); printf("input integer:"); scanf("%d",p); printf("\nx = %d\n", x); printf("address of x = %p\n", &x); printf("p = %p\n", p); } return(0);

27 1 #include <stdio.h> 2 3 void change(int *a, int *b) 4 { 5 int c; 6 7 c = *a; 8 *a = *b; 9 *b = c; } void badchange(int a, int b) 14 { 15 int c; c = a; 18 a = b; 19 b = c; 20 } int main() 23 { 24 int x,y; x=1; 27 y=2; 28 printf("x = %d, y = %d\n",x,y); 29 badchange(x,y); 30 printf("x = %d, y = %d\n",x,y); 31 change(&x,&y); 32 printf("x = %d, y = %d\n",x,y); 33

28 34 return(0); 35 } 36 badchange() a b badchange() badchange() badchange() main() change() scanf()

29 janken_2.c 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #define GU "\n nnnn\ncuuuu\n" 5 #define TYOKI "\n n n\n //\n N\n \\ /\n" 6 #define PA "\nnnnn\n /\\\n / /\n\\ /\n" 7 8 int ran_123() 9 { 10 static int first=1; 11 time_t now; 12 char *time_char; 13 char ctmp[10]; 14 int hour, min, sec, tmp; 15 unsigned seed; if(first){ 18 time(&now); 19 time_char = ctime(&now); 20 sscanf(time_char,"%s %s %d %d:%d:%d %d\n", ctmp, ctmp, &tmp, 21 &hour, &min, &sec, &tmp); 22 printf("%d:%d:%d\n", hour, min, sec); 23 seed = hour+min+sec; 24 srand(seed); 25 first = 0; 26 } return(rand()%3);

30 29 } int janken() 32 { 33 char man, pc, tmp; 34 char *man_no_te, *pc_no_te; printf("let's do JAN-KEN with me!!!!!\n"); 37 printf("jan-ken-pon \ngu: %s\n TYOKI: %s\n PAH: %s\n\n", GU, TYOKI, PA); 38 printf("input your choice from G, T and P (for GU, TYOKI, PAH)\n"); 39 printf("-->"); 40 scanf("%c", &man); 41 scanf("%*c",&tmp); if(man == 'g'){ 44 man='g'; 45 man_no_te = GU; 46 }else if(man == 'G'){ 47 man_no_te = GU; 48 }else if(man == 't'){ 49 man='t'; 50 man_no_te = TYOKI; 51 }else if(man == 'T'){ 52 man_no_te = TYOKI; 53 }else if(man == 'p'){ 54 man = 'P'; 55 man_no_te = PA; 56 }else if(man == 'P'){ 57 man_no_te = PA; 58 } pc = ran_123(); 61 if(pc == 0){ 62 pc = 'G';

31 63 pc_no_te = GU; 64 } 65 if(pc == 1){ 66 pc = 'T'; 67 pc_no_te = TYOKI; 68 } 69 if(pc == 2){ 70 pc = 'P'; 71 pc_no_te = PA; 72 } printf("you:\n %s \ni CPU:\n %s \n", man_no_te, pc_no_te); 75 if((man == 'G' && pc == 'P') (man == 'T' && pc == 'G') 76 (man == 'P' && pc == 'T')){ 77 printf("i CPU won.\n"); 78 return(1); 79 }else if(man == pc){ 80 printf("draw.\n"); 81 return(0); 82 }else{ 83 printf("you won.\n"); 84 return(-1); 85 } } int main() 90 { 91 janken(); 92 return(0); 93 } 94

32 GU "\n nnnn\ncuuuu\n" ran_123() ran_012() ran_123() first first 1 first 1 time() time_t now ctime() time_char sscanf() hour min sec seed srand() srans() rand() seed first rand() janken() janken_1.c main()

33 while janken()

34 1 #include <stdio.h> 2 #include <stdlib.h> 3 #define FILENAME "myfile.txt" 4 #define DATAN int main() 7 { 8 FILE *fp; 9 int c,rnum; if((fp = fopen(filename,"w")) == NULL){ 12 printf("can not open the file '%s'.\n",filename); 13 return(1); 14 } for(c=0;c<datan;c++){ 17 rnum = rand(); 18 fprintf(fp,"%d\n",rnum%40); 19 printf("%d\n",rnum%40); 20 } fclose(fp); 23 return(0); 24 } 25

35 1 #include <stdio.h> 2 #include <stdlib.h> 3 #define FILENAME "myfile.txt" 4 #define DATAN int main() 7 { 8 FILE *fp; 9 int c,rnum; if((fp = fopen(filename,"r")) == NULL){ 12 printf("can not open the file '%s'.\n",filename); 13 return(1); 14 } for(c=0;c<datan;c++){ 17 fscanf(fp,"%d\n",&rnum); 18 printf("%d\n",rnum); 19 } fclose(fp); 22 return(0); 23 } 24

36 1 #include <stdio.h> 2 #include <stdlib.h> 3 #define FILENAME "myfile.txt" 4 #define DATAN void change(int *a, int *b); 7 8 void change(int *a, int *b) 9 { 10 int c; c = *a; 13 *a = *b; 14 *b = c; } int main() 19 { 20 FILE *fp; 21 int c,rnum[datan],i,j; if((fp = fopen(filename,"r")) == NULL){ 24 printf("can not open the file '%s'.\n",filename); 25 return(1); 26 } for(c=0;c<datan;c++){ 29 fscanf(fp,"%d\n",rnum+c); 30 printf("%d\n",rnum[c]); 31 }

37 32 33 for(i=0;i<datan-1;i++){ 34 for(j=datan-1;j>i;j--){ 35 if(rnum[j] < rnum[j-1]){ 36 change(rnum+j, rnum+j-1); 37 } 38 } 39 } printf("########\n"); for(c=0;c<datan;c++){ 44 printf("%d\n",rnum[c]); 45 } fclose(fp); 48 return(0); 49 } 50

38 2 x t 2 = a, a x t = at + A, x = 1 2 at2 + At + B, A, B x t x(t) p(t) = t x(t), t t p(t) t = a, x(t) t = p(t), t j = j t, p j = p(j t), x j = x(j t), p j+1 p j + a t, x j+1 x j + p j t, p(0) = 0 x(0) = 0 A = 0 B = 0

39 t = 0.1 p 1 p a, x 1 x p 0, p 2 p a, x 2 x p 1, p(0) = 0 x(0) = 0 a = 2.0 t = t 10.0 t j, p(t j ), x(t j ), p j, x j deq.txt p(t j ), x(t j ) t j deq.txt t

40 main2d.c ~/nrps main2d.c $ cd ~/nrps $./c main2d $./main2d.out 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 5 #define WIDTH #define HIGHT void display(void); 9 void reshape(int w, int h); 10 void keyboard(unsigned char key, int x, int y); 11 void ginit(int* pargc, char** argv); void display(void) 14 { 15 int i, j; glclear(gl_color_buffer_bit); 18 glpointsize(1); 19 glbegin(gl_points); 20 glcolor3f(1.0,0.0,0.0); /* red */ 21 glvertex2f(1,1); 22 glcolor3f(0.0,1.0,0.0); /* green */

41 23 glvertex2f(2,2); 24 glcolor3f(0.0,0.0,1.0); /* blue */ 25 glvertex2f(3,3); glend(); 28 glutswapbuffers(); 29 } void reshape(int w, int h) 32 { 33 glviewport(0, 0, (GLsizei)w, (GLsizei)h ); 34 glmatrixmode(gl_projection); 35 glloadidentity(); 36 gluortho2d(0.0, (GLdouble)w, 0.0, (GLdouble) h); 37 } void keyboard(unsigned char key, int x, int y) 40 { 41 switch(key) { 42 case 'q': 43 case 'Q': 44 exit(0); 45 break; 46 case ' ': 47 glutidlefunc(0); 48 break; 49 default: 50 break; 51 } 52 } void ginit(int* pargc, char** argv) 55 { 56 glutinit(pargc,argv);

42 57 glutinitdisplaymode(glut_double GLUT_RGB); 58 glutinitwindowsize(width,hight); 59 glutinitwindowposition(100,50); 60 glutcreatewindow("numerical Recipes for Polymer Science"); 61 glclearcolor(0.0,0.0,0.0,0.0); /* background color */ 62 glshademodel(gl_flat); 63 glutdisplayfunc(display); 64 glutreshapefunc(reshape); 65 glutkeyboardfunc(keyboard); 66 } int main(int argc, char* argv[]) 69 { 70 ginit(&argc,argv); 71 glutmainloop(); 72 return 0; 73 } WIDTH HIGHT WIDTH 300 reshape void int display glutdisplayfunc(display) display

43 i j display() 1 glbegin() glend() glbegin(gl_points) glbegin(gl_lines) glbegin(gl_line_strip) glbegin(gl_line_loop) glbegin(gl_triangles / GL_QUADS) glbegin(gl_trianble_strip / GL_QUAD_STRIPE) glbegin(gl_triangle_fan) glbegin(gl_polygon) glcolor3f() glvertex2f(float x, float y) (x, y) glutswapbuffers() reshape(int w, int h) glutreshapefunc() glutkeyboardfunc() ginit(int* pargc, char** argv)

44 main() main().c 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 double f2bai(double x); 5 double tasu(double x, double y); 6 7 double f2bai(double x) 8 { 9 printf("f2bai works.\n"); return(2.0*x); 12 } double tasu(double x, double y) 15 { 16 return(x+y); 17 } int main() 20 { 21 double a,b; a = (rand()%1000)/1000.0; 24 b = (rand()%1000)/1000.0;

45 25 26 printf("2*%lf = %lf\n", a, f2bai(a)); 27 printf("%lf + %lf = %lf\n", a, b, tasu(a,b)); return(0); 30 } ~/nrps $ pwd main2d.c hexagon.c $ cp main2d.c hexagon.c 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> * 4 #include <math.h> 5 6 #define WIDTH #define HIGHT 300 * 8 #define RADIUS 100 * 9 #define X0 150 *10 #define Y void display(void) 18 {

46 *19 int x, y, deg; glclear(gl_color_buffer_bit); 22 glpointsize(1); *23 glbegin(gl_line_loop); *24 glcolor3f(1.0, 1.0, 0.0); /* yellow */ *25 for(deg = 0; deg < 360; deg = deg+60){ *26 x = RADIUS*cos(deg*M_PI/180); *27 y = RADIUS*sin(deg*M_PI/180); *28 glvertex2f(x0+x,y0+y); *29 } 30 glend(); 31 glutswapbuffers(); 32 } hexagon.c math.h RADIUS X0 Y0 display() hexagon.c hexagon.c 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 #include <math.h> * 5 #include <time.h> 6

47 7 #define WIDTH #define HIGHT #define RADIUS #define X #define Y0 150 *12 #define DEGSTEP void display(void); 15 void reshape(int w, int h); 16 void keyboard(unsigned char key, int x, int y); 17 void ginit(int* pargc, char** argv); *18 void idle(void); 19 *20 int Degshift=0; 21 *22 void idle(void) *23 { *24 static int first = 1; *25 static time_t past; *26 time_t now; *27 *28 if(first == 1){ *29 time(&past); *30 first = 0; *31 return; *32 } *33 *34 time(&now); *35 *36 if(difftime(now,past) > 1.0){ *37 Degshift += DEGSTEP; *38 past = now; *39 } *40

48 *41 glutpostredisplay(); *42 } void display(void) 45 { 46 int x, y, deg; glclear(gl_color_buffer_bit); 49 glpointsize(1); 50 glbegin(gl_polygon); 51 glcolor3f(1.0, 1.0, 0.0); /* yellow */ 52 for(deg = 0; deg < 360; deg = deg+60){ *53 x = RADIUS*cos((deg+Degshift)*M_PI/180); *54 y = RADIUS*sin((deg+Degshift)*M_PI/180); 55 glvertex2f(x0+x,y0+y); 56 } 57 glend(); 58 glutswapbuffers(); 59 } void reshape(int w, int h) 62 { 63 glviewport(0, 0, (GLsizei)w, (GLsizei)h ); 64 glmatrixmode(gl_projection); 65 glloadidentity(); 66 gluortho2d(0.0, (GLdouble)w, 0.0, (GLdouble) h); 67 } void keyboard(unsigned char key, int x, int y) 70 { 71 switch(key) { 72 case 'q': 73 case 'Q': 74 exit(0);

49 75 default: 76 break; 77 } 78 } void ginit(int* pargc, char** argv) 81 { 82 glutinit(pargc,argv); 83 glutinitdisplaymode(glut_double GLUT_RGB); 84 glutinitwindowsize(width,hight); 85 glutinitwindowposition(100,50); 86 glutcreatewindow("numerical Recipes for Polymer Science"); 87 glclearcolor(0.0,0.0,0.0,0.0); /* background color */ 88 glshademodel(gl_flat); 89 glutdisplayfunc(display); 90 glutreshapefunc(reshape); 91 glutkeyboardfunc(keyboard); *92 glutidlefunc(idle); 93 } int main(int argc, char* argv[]) 96 { 97 ginit(&argc,argv); 98 glutmainloop(); 99 return 0; 100 } 101 rothex.c time() time.h.h

50 DEGSTEP idle(void) Degshift glutidlefunc() 1 0 first static static time.h time_t now past now past time(&past) first return if time(&now) now difftime(now,past) now past Degshift DEGDTEP now past

51 idle(void)

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena $ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a $ ls -l $ ls -l -a $ ls -la $ ls -F $ ls $ cd $ cd $ pwd $ cat

More information

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E 8 9 7 6 4 2 3 5 1 j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E a n 1 H = ae l j, j=1 l j = x j+1 x j, x n x 1 = n 1 j=1 l j, l j = ±l l > 0) n 1 H = ϵ l j, j=1 ϵ e x x

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 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h> 2007 12 5 1 2 2.1 ( ) 1 1: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 #define H WIN 400 // 8 #define W WIN 300 // 9

More information

#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta

#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta 1 1. 1 #include 2 #include 3 #include 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 static bool KeyDownON = false; // 8 static bool KeyLeftON

More information

第3章 OpenGL の基礎

第3章 OpenGL の基礎 3 OpenGL April 11, 2017 1 / 28 3.1 ( ) OpenGL OpenGL 2 / 28 3.2 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc. 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh

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

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

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

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

1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - >

1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 8 (240 O p e n C V ) 9 opencv_core240d.lib 10 opencv_imgproc240d.lib

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

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

/*p7-1-1*/

/*p7-1-1*/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 /* e8.c Copyright (c) 2003 by T. HAYASHI and

More information

演算増幅器

演算増幅器 コンピュータグラフィックス 2 前回は GLUT を使った簡単な 2 次元グラフィックスについて習った 今週は以下の項目について 補足していく イベント駆動型プログラムの動作について コンピュータグラフィックスの座標系 イベント駆動型プログラム従来のプログラムとの違いこれまでに学習してきたプログラムは上から下に順次実行され 条件分岐や繰り返し処理によって プログラムの流れ (flow: フロー )

More information

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

Microsoft PowerPoint - program.ppt [互換モード] プログラミング演習 バージョン 1 担当教員 : 綴木馴 プログラムの決まりについて学ぶ おすすめする参考書 ザ C 戸川隼人サイエンス社 本日の予定 1. 授業の説明. 2. コンパイラーのインストール. プログラムの決まりについて学ぶ,P31 /* The most in C */ /* hello.c */ printf("hello,world n"); プログラムの決まり ( コメント )

More information

3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程

3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程 3. 3D ビューイング 1. 3Dグラフィックス処理の一般過程 2. 射影と射影変換 3. ビューボリュームとクリッピング 4. 陰面処理とデプスバッファ 5. ビューポート変換 6. 3Dグラフィックスを描く 7. モデルビュー変換 3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程 3D グラフィックス処理の一般過程 1. モデリング変換 座標系の異なる複数のオブジェクトを仮想世界に配置し,

More information

第3章 OpenGL の基礎

第3章 OpenGL の基礎 3 OpenGL April 20, 2012 1 / 23 31 ( ) OpenGL OpenGL 2 / 23 32 OpenGL OpenGL OpenGL (Open Graphics Library) Silicon Graphics, Inc 2 3 API (Application Program Interface) [4] UNIX OS Windows Macintosh CAD

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

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

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

超初心者用

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

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

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

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

Informatics 2010.key

Informatics 2010.key http://math.sci.hiroshima-u.ac.jp/ ~ryo/lectures/informatics2010/ 1 2 C ATM etc. etc. (Personal Computer) 3 4 Input Output Device Central Processing Unit I/O CPU Memory 5 6 (CPU),,... etc. C, Java, Fortran...

More information

新版明解C言語 実践編

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

C B

C B C 095707B 2010 6 8 1 LEVE1 2 1.1 LEVEL 1.1................................................ 2 1.1.1 1................................................ 2 1.1.2 1.2..............................................

More information

謗域・ュ逕ィppt

謗域・ュ逕ィppt 情報工学 2017 年度後期第 5 回 [11 月 1 日 ] 静岡大学 工学研究科機械工学専攻ロボット 計測情報講座創造科学技術大学院情報科学専攻 三浦憲二郎 講義日程 第 6 回 11 月 8 日画像処理パート第 1 回 第 7 回 11 月 15 日 CGパート第 6 回 第 8 回 11 月 22 日 CGパート第 7 回 第 9 回 11 月 29 日 CGパート試験 講義アウトライン [11

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

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

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

libaux.dvi

libaux.dvi AUX OpenGL 1 OpenGL (AUX libaux.a) OpenGL Programming Guide () OpenGL 1 OpenGL OS (API) OS OS OS OpenGL Windows Windows X X OpenGL Programming Guide AUX toolkit AUX OS OpenGL SGI OpenGL OS OpenGL AUX Windows

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

2 : 2008/12/ /01/ G :

2 : 2008/12/ /01/ G : 2 : 2008/12/08 2008/01/16 075730G : 1 project draw main.cpp 1 draw main.cpp /* * main.cpp * draw * * Created by C-T on 08/12/08. * Copyright 2008 MyCompanyName. All rights reserved. * */ #include

More information

演算増幅器

演算増幅器 スペースインベーダーもどき 1000 行プログラムの参考として スペースインベーダーもどきのプログラムを配布する いくつか習って いないものもあるので 補足の説明を加えていく 文字列の描画 文字の描画は glutbitmapcharacter() を用いる これは以下のようにして利用する int i; char *str = "Display String"; glcolor3f(0.0, 0.0,

More information

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber();

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber(); : : :0757230G :2008/07/18 2008/08/17 1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include class Number Number(); // ~Number(); // void setnumber(float n); float getnumber(); private: float num; ;

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

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

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

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

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

More information

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

(search: ) [1] ( ) 2 (linear search) (sequential search) 1 2005 11 14 1 1.1 2 1.2 (search:) [1] () 2 (linear search) (sequential search) 1 2.1 2.1.1 List 2-1(p.37) 1 1 13 n

More information

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C 1 6 9 1 main main 1 NULL NULL 1 15 23 25 48 26 30 32 36 38 43 45 47 50 52 for 2 (a) 2 2 1 Yacc 2 (b) 2 3 yytext tmp2 ("") tmp2->next->word tmp2 yytext tmp2->next->word

More information

C

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

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

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

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

: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

kiso2-09.key

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

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

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

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

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

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

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

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

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

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

2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix()

2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix() 1 20 (2) OpenGL+GUI(GLUI) 3DCG TA 2008 10 27 1 OpenGL OpenGL GUI GLUI 1.1 http://www.cyber.t.u-tokyo.ac.jp/~kuni/enshu2008/ 1.2 TA 1.3 2008/12/4( ) EyeToy 2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut

More information

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

Microsoft Word - Cプログラミング演習(12) 第 12 回 (7/9) 4. いくつかのトピック (5)main 関数の引数を利用したファイル処理 main 関数は, 起動する環境から引数を受け取ることができる 例えば 次に示すように,main 関数に引数を用いたプログラムを作成する 01 /* sample */ 02 /* main 関数の引数 */ 03 #include 04 05 main(int argc, char

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

導入基礎演習.ppt

導入基礎演習.ppt Multi-paradigm Programming Functional Programming Scheme Haskell ML Scala X10 KL1 Prolog Declarative Lang. C Procedural Lang. Java C++ Python Object-oriented Programming / (root) bin home lib 08 09

More information

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 プレゼンテーション

PowerPoint プレゼンテーション 2018/10/05 竹島研究室創成課題 第 2 回 C 言語演習 変数と演算 東京工科大学 加納徹 前回の復習 Hello, world! と表示するプログラム 1 #include 2 3 int main(void) { 4 printf("hello, world! n"); 5 return 0; 6 } 2 プログラム実行の流れ 1. 作業ディレクトリへの移動 $ cd

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

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 による数値計算法入門 ( 第 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

橡Pro PDF

橡Pro PDF 1 void main( ) char c; /* int c; */ int sum=0; while ((c = getchar())!= EOF) if(isdigit(c) ) sum += (c-'0'); printf("%d\n", sum); main()int i,sum=0; for(i=0;i

More information

2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN, IBM UNIX Linux, FreeBSD PC UNIX Windows, Mac OS API PD

2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN, IBM UNIX Linux, FreeBSD PC UNIX Windows, Mac OS API PD 1 2015 5-1 2015 6 22 1 3DCG 3DCG 3DCG OpenGL OS Linux(Ubuntu) 1.1 TA 1.2 http://www.cyber.t.u-tokyo.ac.jp/~tani/class/mech_enshu/ 2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI)

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

Ⅰ 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

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

P05.ppt

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

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.ppt

1.ppt /* * Program name: hello.c */ #include int main() { printf( hello, world\n ); return 0; /* * Program name: Hello.java */ import java.io.*; class Hello { public static void main(string[] arg)

More information

新・明解C言語で学ぶアルゴリズムとデータ構造

新・明解C言語で学ぶアルゴリズムとデータ構造 第 1 章 基本的 1 n 141 1-1 三値 最大値 algorithm List 1-1 a, b, c max /* */ #include int main(void) { int a, b, c; int max; /* */ List 1-1 printf("\n"); printf("a"); scanf("%d", &a); printf("b"); scanf("%d",

More information

slide5.pptx

slide5.pptx ソフトウェア工学入門 第 5 回コマンド作成 1 head コマンド作成 1 早速ですが 次のプログラムを head.c という名前で作成してください #include #include static void do_head(file *f, long nlines); int main(int argc, char *argv[]) { if (argc!=

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

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t 1 22 (2) OpenGL+GUI(GLUI) 3DCG TA 2010 10 18 1 OpenGL OpenGL GUI GLUI 1.1 http://www.cyber.t.u-tokyo.ac.jp/~kuni/enshu2010/ 1.2 TA 1.3 2010/12/6( ) USB 2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height

More information

準備 計算結果を可視化するために OpenGL を 利用する. 2

準備 計算結果を可視化するために OpenGL を 利用する. 2 2. 2 次元粒子法シミュレーション (+ 少しだけ OpenGL) 茨城大学工学部 教授乾正知 準備 計算結果を可視化するために OpenGL を 利用する. 2 OpenGL 3 次元コンピュータグラフィックス用の標準的なライブラリ. 特に CAD やアート, アニメーション分野 ( ゲーム以外の分野 ) で広く利用されている. OpenGL は仕様がオープンに決められており, 企業から独立した団体が仕様を管理している.

More information

I117 7 School of Information Science, Japan Advanced Institute of Science and Technology

I117 7 School of Information Science, Japan Advanced Institute of Science and Technology I117 7 School of Information Science, Japan Advanced Institute of Science and Technology time time t long typedef long time_t; 1970/01/01 0:00:00 time t = time(null); Japan Advanced Institute of Science

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

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

#define N1 N+1 double x[n1] =.5, 1., 2.; double hokan[n1] = 1.65, 2.72, 7.39 ; double xx[]=.2,.4,.6,.8,1.2,1.4,1.6,1.8; double lagrng(double xx); main

#define N1 N+1 double x[n1] =.5, 1., 2.; double hokan[n1] = 1.65, 2.72, 7.39 ; double xx[]=.2,.4,.6,.8,1.2,1.4,1.6,1.8; double lagrng(double xx); main =1= (.5, 1.65), (1., 2.72), (2., 7.39).2,.4,.6,.8, 1., 1.2, 1.4, 1.6 1 1: x.2 1.4128.4 1.5372.6 1.796533.8 2.198 1.2 3.384133 1.4 4.1832 1.6 5.1172 8 7 6 5 y 4 3 2 1.5 1 1.5 2 x 1: /* */ #include

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

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

Microsoft Word - no15.docx

Microsoft Word - no15.docx ex33.c /* */ #define IDLENGTH 7 /* */ #define MAX 100 /* */ /* */ struct student char idnumber[idlength + 1]; /* */ int math; /* () */ int english; /* () */ int japanese; /* () */ double average; /* */

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

2 T ax 2 + 2bxy + cy 2 + dx + ey + f = 0 a + b + c > 0 a, b, c A xy ( ) ( ) ( ) ( ) u = u 0 + a cos θ, v = v 0 + b sin θ 0 θ 2π u = u 0 ± a

2 T ax 2 + 2bxy + cy 2 + dx + ey + f = 0 a + b + c > 0 a, b, c A xy ( ) ( ) ( ) ( ) u = u 0 + a cos θ, v = v 0 + b sin θ 0 θ 2π u = u 0 ± a 2 T140073 1 2 ax 2 + 2bxy + cy 2 + dx + ey + f = 0 a + b + c > 0 a, b, c A xy u = u 0 + a cos θ, v = v 0 + b sin θ 0 θ 2π u = u 0 ± a cos θ, v = v 0 + b tan θ π 2 < θ < π 2 u = u 0 + 2pt, v = v 0 + pt

More information

AutoTuned-RB

AutoTuned-RB ABCLib Working Notes No.10 AutoTuned-RB Version 1.00 AutoTuned-RB AutoTuned-RB RB_DGEMM RB_DGEMM ( TransA, TransB, M, N, K, a, A, lda, B, ldb, b, C, ldc ) L3BLAS DGEMM (C a Trans(A) Trans(B) b C) (1) TransA:

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

第5回お試しアカウント付き並列プログラミング講習会

第5回お試しアカウント付き並列プログラミング講習会 qstat -l ID (qstat -f) qscript ID BATCH REQUEST: 253443.batch1 Name: test.sh Owner: uid=32637, gid=30123 Priority: 63 State: 1(RUNNING) Created at: Tue Jun 30 05:36:24 2009 Started at: Tue Jun 30 05:36:27

More information

初歩のC言語ターミナル_2014_May.pages

初歩のC言語ターミナル_2014_May.pages C Mac OS X ( Vi Mi) Xcode CD >cd C:\Users\\Desktop gcc first.c C:\Users\\Desktop>gcc -o first first.c gcc first.c C:\Users\\Desktop>first Windows OS VisualStudio VisualStudio VS2012 CD C:\ >cd C:\Users\

More information

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

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

More information

8 / 0 1 i++ i 1 i-- i C !!! C 2

8 / 0 1 i++ i 1 i-- i C !!! C 2 C 2006 5 2 printf() 1 [1] 5 8 C 5 ( ) 6 (auto) (static) 7 (=) 1 8 / 0 1 i++ i 1 i-- i 1 2 2.1 C 4 5 3 13!!! C 2 2.2 C ( ) 4 1 HTML はじめ mkdir work 作業用ディレクトリーの作成 emacs hoge.c& エディターによりソースプログラム作成 gcc -o fuga

More information

/* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLU

/* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLU OpenGL ( ) #include #include #define PI 3.14159265 void function_graph() int j; float x, y; glbegin( GL_LINE_STRIP );// sine curve by line glcolor3f( 0.0f, 1.0f, 1.0f );// line color

More information

P06.ppt

P06.ppt p.130 p.198 p.208 2 1 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i < NUM; i++ ) if ( weight[i] > max ) max = weight[i]: if ( weight[i] < min ) min = weight[i]: weight 3 maxof(a,

More information

Microsoft PowerPoint - 説明3_if文switch文(C_guide3)【2015新教材対応確認済み】.pptx

Microsoft PowerPoint - 説明3_if文switch文(C_guide3)【2015新教材対応確認済み】.pptx 情報ネットワーク導入ユニット Ⅰ C 言語 if 文 switch 文 3 章 : プログラムの流れの分岐 if 文 if( 条件 ) 条件が成立すれば実行 if( 条件 ) ~ else 場合分け ( 成立, 不成立 ) if( 条件 A) ~ else if( 条件 B) ~ else if( 条件 C) ~ else 場合分け ( 複数の条件での場合分け ) 等価演算子 : == ( 等しい

More information