2 1
list0415.c forfor #include <stdio.h> int i, j; for (i = 1; i <= 9; i++) for (j = 1; j <= 9; j++) printf( "%3d", i * j ); printf( \n ); 3 forfor ifif for for (i = 1; i <= 9; i++) for for (j = 1; j <= 9; j++) printf( \n ); i=1 printf( "%3d", i * j ); j=19 1 19 i=2 1 2 3 4 5 6 7 8 9\n 2 4 6 8 10 12 14 16 18\n i 4 2
list0417.c #include <stdio.h> int i, j; int width, height; puts( "); printf(""); scanf("%d", &width); printf(""); scanf("%d", &height); for (i = 1; i <= height; i++) for (j = 1; j <= width; j++) printf( * ); printf( \n ); 5 2 1 int ma[2]; i ma[0] i=0 ma[1] i=1 2 j=0 j=1 j=2 i j int ma[2][3]; i=0 i=1 ma[0][0] ma[1][0] ma[0][1] ma[1][1] ma[0][2] ma[1][2] 2 x 3 2 6 3
list0514.c 2 #include <stdio.h> int i, j; int ma[2][3] = 1, 2, 3, 4, 5, 6 ; int mb[2][3] = 6, 3, 4, 5, 1, 2 ; int mc[2][3] = 0 ; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) mc[i][j] = ma[i][j] + mb[i][j]; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%3d", mc[i][j]); printf( \n ); 7 2 int ma[2][3] = 1, 2, 3, 4, 5, 6 ; int mb[2][3] = 6, 3, 4, 5, 1, 2 ; int mc[2][3] = 0 ; 1, 2, 3 0 ma[0][0] ma[1][0] ma[0][1] ma[1][1] ma[0][2] ma[1][2] 4, 5, 6 8 4
2?x? Pixel 2image[ i ][ j ] RGB 9 printf, puts, putchar scanf 10 5
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]: etc 11 include <stdio.h> return(0); main C main 12 6
printf( dn, num ); puts( scanf( d, &num ); C 13 14 7
include <stdio.h> printf(); scanf(); return(0); include stdio.h> (Standard input output header) printf, puts, scanf printf stdio.h 15 list0601.c (p.115) include <stdio.h> int maxof(int x, int y) if (x > y) else int na, nb, max; return (x); return (y); puts(" printf(" scanf("%d", &na); printf(" scanf("%d", &nb); max = maxof( na, nb ); printf("dn", max ); main 16 8
maxof int int int maxof( int x, int y ) if (x > y) return (x); else return (y); int int maxof return 17 maxof main int na, nb, max; max = maxof( na, nb ); maxof(na, nb) int maxof( int x, int y ) if (x > y) return (x); else return (y); maxof 18 9
main int na, nb, max; na = 24; nb = 62; max = maxof( na, nb ); return int maxof( int x, int y ) na, nbx, y if (x > y) return (x); else return (y); 19 List0601int int minof(int x, int y) main include <stdio.h> int minof(int x, int y) if (x < y) else int na, nb, min; return (x); return (y); puts(" printf(" scanf("%d", &na); printf(" scanf("%d", &nb); min = minof( na, nb ); printf( dn", min ); 20 10
list0602.c (p.118) double include <stdio.h> double max3(double x, double y, double z) double max = x; if (y > max) max = y; if (z > max) max = z; return (max); double na, nb, nc; puts( printf( scanf("%lf", &na); printf( scanf("%lf", &nb); printf( scanf("%lf", &nc); double scanflf printf( f n", max3(na, nb, nc)); 21 double max3(double x, double y, double z) double max = x; if (y > max) max = y; if (z > max) max = z; return (max); double max printf( f n", max3(na, nb, nc)); 22 11
menseki.c a, b a, b b S include <stdio.h> a double menseki(double x, double y ) double s; s = x * y / 2.0; return( x * y / 2.0 ); return (s); double a, b; puts( printf( scanf("%lf", &a); printf( scanf("%lf", &b); printf( f n", menseki( a, b) ); 23 hello.c Hello! include <stdio.h> void hello(void) puts( Hello!! ); hello( ); 24 12
void hello(void) void void main int(0) 25 no void put_stars( int no ) stars.c include <stdio.h> void put_stars( int no ) while( no-- > 0 ) putchar( * ); --no > 0 int x; printf( input no: ); scanf( %d, &x ); put_stars( x ); 26 13
while( no-- > 0 ) putchar( * ); no : 5 4 3 2 1 no > 0 no-- no while( --no > 0 ) putchar( * ); no : 4 3 2 1 no-- no > 0 27 main 28 14
1x int kaijou( int x ) main kadai5-1.c for2 kadai5-2.c 32x3(A)3x2B kadai5-3.c A = 1 2 3 1 5 B = 5 3 4 5 6 8 1 29 4 5 30 15