超初心者用

Similar documents
A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology

1.ppt

joho07-1.ppt

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

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

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

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

P05.ppt

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

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

Taro-ファイル処理(公開版).jtd

ohp03.dvi

ファイル入出力

ポインタ変数

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

ポインタ変数

10

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

r08.dvi

I J

PowerPoint Presentation

Informatics 2014

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

r03.dvi


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

PowerPoint Presentation

ファイル入出力

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

卒 業 研 究 報 告.PDF

program.dvi

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

ohp08.dvi

PowerPoint プレゼンテーション

Informatics 2015

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

file"a" file"b" fp = fopen("a", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose(fp); fp = fopen("b", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose

untitled

double float

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

導入基礎演習.ppt

(K&R 2.9) ~, &,, >>, << 2. (K&R 5.7) 3. (K&R 5.9) 4. (K&R 5.10) (argc argv atoi(), atof() ) 5. (K&R 7.5) (K&R 7.6) - FILE, stdin, stdout, std


main

PowerPoint プレゼンテーション

untitled

Informatics 2010.key

comment.dvi

r07.dvi

ohp07.dvi

Minimum C Minimum C Minimum C BNF T okenseq W hite Any D

untitled

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


: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

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)* (

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

pptx

新・明解C言語 ポインタ完全攻略

計算機プログラミング

Taro-リストⅢ(公開版).jtd

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

プログラミング基礎

gengo1-12

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

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B

情報処理演習 B8クラス

Microsoft Word - C.....u.K...doc

ex14.dvi

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

Microsoft PowerPoint - guidance.ppt

gengo1-12

C

Microsoft Word - 3new.doc

Microsoft PowerPoint - kougi9.ppt

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

‚æ2›ñ C„¾„ê‡Ìš|

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.

PowerPoint プレゼンテーション

C言語によるアルゴリズムとデータ構造

Cプログラミング - 第8回 構造体と再帰

gengo1-12

memo

tuat1.dvi

橡Pro PDF

K227 Java 2

データ構造

lexex.dvi

プログラミング基礎

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

untitled

+ +

練習&演習問題

PowerPoint プレゼンテーション

I void* School of Information Science, Japan Advanced Institute of Science and Technology

ex01.dvi

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

Transcription:

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 int num; num = 100; printf( I got number %d n, num); 3

printf( %d n, num)num %d printf( I got number %d n, num); I got number 100 main double double num; num = 12.34; printf( I got number %lf n, num); num printf %lf char char c; c = X ; printf( I got letter %c n, num); c printf %c 123 4. double x, y, z; 4

x = 100.0; y = 200.0; z = (x + y) / 2.0; printf( Average is %lf n, z); x,y,z x100 100.0 y200 z(x + y)/2 ( (100 + 200) / 2) z +, -, *, / ( ) 100.0 / 8.1 * 60 * 60 5. if int x; x = 20; if(x > 10){ printf( Hello! n ); else { printf( Hi! n ); Hello! x = 20;x = 5 Hi! if if( ){ 5

else { ; ; x > 10 x 10 printf( Hello! n ); printf( Hi! else n 100 Big number!100 Small number! 6. while int x; x = 100; while(x <= 300){ printf( The number I got is now %d. n, x); x = x + 50; The number I got is now 100. The number I got is now 150. The number I got is now 200. The number I got is now 250. The number I got is now 300. while while 6

while( ){ 1; 2; : { while 1 2 : x 100 x 300 while x = x + 50 x 50 x while 100,150,200,250,300 printf while 1,3,5,7,..21 while 1 + 3 + 5 + + 21 7

7. scanf scanf( %d, &n); int n %d (& ) # include <stdio.h> int x, y; printf( Input first number: ); scanf( %d, &x); printf( Input second number: ); scanf( %d, &y); printf( %d + %d = %d n, x, y, x + y); %./a.out Input first number: 10 Input second number: 20 10 + 20 = 30 % scanf( %d, &x); x 8

8. int array[5]; array[0] array[4] array[3] = 100; array[0] array[1] array[2] array[3] array[4] 100 [ ] ; int array[3]; int x,n; n = 0; while(n < 3){ printf( Please input number : ); scanf( %d, &x); array[ n ] = x; n = n + 1; n = 0; while(n < 3){ 9

printf( No. %d -> %d n, n, array[n]); n = n + 1; Please input number : 25 Please input number : 21 Please input number : 39 No. 0 -> 25 No. 1 -> 21 No. 2 -> 39 n while n 9. C a t Hello, Good C char char str[7]; str #include <string.h> 10

strcpy(str, Hello ); strcpy 0 str[0] str[1] str[2] str[3] str[4] str[5] str[6] H e l l o 0 str[1] e printf( %c n, str[1]); e printf( %s n, str); %s printf( %s n, &str[3]); lo & str str[3] 3 &str[3] 3 Mothers strcmp(str1, str2); /* str1 str2 0 */ strncmp(str1, str2, n); /* str1 str2 n 0 */ strcat(str1, str2); /* str1 str2 */ 11

strlen(str1); /* str1 strcmp #include <string.h> char str1[20], str2[20]; scanf( %s, str1); scanf( %s, str2); if(strcmp(str1, str2) == 0)printf( Same strings n ); /* str1 str2 (0) Same strings */ else printf( Different strings n ); strcat 10. (){ : : (); 12

Hello print_hello(){ printf( Hello n ); print_hello(); /* */ print_hello(){ printf( Hello ); print_hello(); printf( End of this program. n ); main print_hello(); main End of this program 13

(10 5) (5 + 10 ( )) = 35 Hello, world print_sum(int x, int y) { printf( %d n, x + y); print_sum(10,20); print_sum x, y 10, 20 30 ( ){ : : x, y 11. cat FILE *fp; 14

fp = fopen( File1, r ); File1 fgets(line, 1000, fp); File1 line line char line[1000]; fclose(fp); char line[1000]; FILE *fp; fp = fopen( File1, r ); while(fgets(line, 1000, fp)!= NULL){ printf( %s, line); fclose(fp); while(fgets(line, 1000, fp)!= NULL){ fgets NULL!= fgets(line, 1000, fp)!= NULL while 15

line line printf( %s, line); 16