ex14.dvi

Similar documents
ex12.dvi

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

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

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

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

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

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

スライド タイトルなし

1. ファイルにアクセスするには ファイルにアクセスするには 1. ファイルを開く 2. アクセスする 3. ファイルを閉じるという手順を踏まなければなりません 1.1. ファイルを読み込む まずはファイルの内容を画面に表示させるプログラムを作りましょう 開始 FILE *fp char fname

July prog11-02.c /*, */ /* $Id: prog11-02.c,v :48:07+09 naito Exp $ */ #include <stdio.h> #define N 10 int main(int argc, cha

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

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

(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

卒 業 研 究 報 告.PDF

slide4.pptx

プログラミング及び演習 第1回 講義概容・実行制御

ohp08.dvi

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

プログラミング及び演習 第1回 講義概容・実行制御

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

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

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

r08.dvi

gengo1-12

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

r03.dvi

計算機プログラミング

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

: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

橡Pro PDF

untitled

ディジタル信号処理

新版明解C言語 実践編

Microsoft PowerPoint - kougi2.ppt

tuat1.dvi

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

Microsoft PowerPoint - kougi9.ppt

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

lexex.dvi

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

P02.ppt

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

1.ppt

PowerPoint Presentation

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

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

I J

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

+ +

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

Microsoft PowerPoint - guidance.ppt

BW BW

r07.dvi

ohp07.dvi

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

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

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

ディジタル信号処理

tuat2.dvi

C言語入門

新・明解C言語 実践編

超初心者用

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

Microsoft Word - no15.docx

演算増幅器

Microsoft Word - no15.docx

PowerPoint プレゼンテーション

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

memo

program.dvi

para02-2.dvi

joho07-1.ppt

V

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

02: 変数と標準入出力

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

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

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

PowerPoint Presentation

memo

Microsoft PowerPoint - kougi4.ppt

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

memo


double float

ex01.dvi

untitled

kiso2-09.key

Microsoft PowerPoint - kougi6.ppt

第7章 有限要素法のプログラミング

Cプログラミング1(再) 第2回

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }

P05.ppt

1 4 2 EP) (EP) (EP)

Microsoft Word - no103.docx

A 30 A A ( ) 2 C C (, machine language) C (C compiler) ( ) Mac Apple Xcode Clan

Apache Web Server 2 Compaq ActiveAnswers Deskpro Compaq Insight Manager Fastart Systempro Systempro/LT ProLiant ROMPaq Qvision SmartStart NetFlex Quic

Transcription:

1,, 0, b (b b 2 b ) n k n = n j b j, (0 n j b 1), n =(n k n k 1...n 1 n 0 ) b, n j j j +1, 0,...,b 1 (digit). b b, n b 1 ñ, ñ = k (b 1 n j )b j b N, n b n, n = b N n, n =ñ+1 b N, n m n + m (mod b N ), b N, b, x k x = n j b j, (0 n j b 1) j=, x =(n k...n 1 n 0.n 1 n 2...) b x b x b x b, b., x b b 2B +1 (B B 1 ) n k n = n j (2B +1) j, ( B n j B), n =(n k n k 1...n 1 n 0 ), b Z/bZ,, 2B +1 Z/(2B +1)Z, B,...,0,...,B

2 2B +1, n n, b (n b 2 ) n k n = n j ( b) j, (0 n j b 1), n =(n k n k 1...n 1 n 0 ) b, b, b = b j k 1 (, b j 2), n n = n 0 + n 1 b 0 + n 2 b 0 b 1 + + n k b 0 b 1 b k 1, n =(n k n k 1...n 1 n 0 ) b j B, B, b = 60, 60, 24, 7, n =(n 4,n 3,n 2,n 1,n 0 ), n 4 weeks n 3 days n 2 hours n 1 miniutes n 0 seconds (n ) Fibonacci F j Fn = F n 1 + F n 2, F 0 =0, F 1 =1 Fibonacci, n, l n = F kj, F kj+1 F kj, F kj+1 F kj, k j+1 >k j +1 n l n = F kj, F kj+1 F kj, n =(k l...k 1 k 0 ). C,,,,,,,,,,,

3,, Fibonacci n,, n ex14-1-1.c 1., 2. feof(stdin) (stdin) 1, 0 3. feof,,,, EOF EOF feof, 1. EOF feof, 0. 4. MAX_CHAR_PAR_LINE buf 5. fgets, fgets buf, MAX_CHAR_PAR_LINE, stdin buf, NULL 6. fgets, fgets,,, EOF fgets, EOF fgets NULL, buf 7. ex14-1-2.c, 8. ex14-1-3.c scanf 9. ex14-1-4.c. a b, n, m scanf,, scanf

4 scanf printf, ex14-2.c 1. ex14-1-1.c, 2., fopen fopen, FILE * stdio.h, feof, fgets stdin fopen fclose 3. fopen, "r" NULL. ex14-3.c : 1. ex14-1-2.c,,,,. 2., fopen "a". fopen 3. printf fprintf ex14-4.c 1. 2. fgets, fprintf, fgets NULL,, printf NULL (0x00), 0x00 3., fread, fwrite fread, fwrite ex14-5.c 1.,,, UNIX wc 2.,, MAX_CHAR_PAR_LINE - 1 3., Windows 2,

5 ex-14-6 1.,,,,, 2., s, atoi int 0 1-2 +3 4 5-6 7 8 +10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10 0 1-2 +3 4 5-6 7 8 +10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, ex-14-7 1. argv argc 2. argv[0]./a.out 1 2 3, argc 4, argv[0]./a.out, argv[1] 1 exercise-14-1 cat [file...] cat, cat file file cat file1 file2 file1, file2 cat exercise-14-2 od file od file 16, file

6 00000000: 20 21 22 23 24 25 26 27 28 29 0a 31 32 33 34 35 00000010: 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 16, 4 8 16, 2 0x36, 0x00000010, 16 ex14-1-1.c /* $Id: ex14-1-1.c,v 1.2 2004-07-12 14:39:34+09 naito Exp $ */ while(!feof(stdin)) if (fgets(buf, MAX_CHAR_PAR_LINE, stdin)!= NULL) printf("%s", buf) ; ex14-1-2.c /* $Id: ex14-1-2.c,v 1.2 2004-07-12 14:39:43+09 naito Exp $ */ while(!feof(stdin)) fgets(buf, MAX_CHAR_PAR_LINE, stdin) ; printf("%s", buf) ;

7 ex14-1-3.c /* $Id: ex14-1-3.c,v 1.2 2004-07-12 14:39:57+09 naito Exp $ */ while(!feof(stdin)) scanf("%s", buf) ; printf("%s\n", buf) ; ex14-1-4.c /* $Id: ex14-1-4.c,v 1.1 2004-07-09 12:56:09+09 naito Exp $ */ int n, m ; scanf("%d %d", &n, &m) ; printf("n = %d, m = %d\n", n, m) ;

8 ex14-2.c /* $Id: ex14-2.c,v 1.2 2004-07-12 14:40:16+09 naito Exp $ */ FILE *in ; if ((in = fopen("ex14-2.c", "r")) == NULL) return -1 ; while(!feof(in)) if (fgets(buf, MAX_CHAR_PAR_LINE, in)!= NULL) printf("%s", buf) ; fclose(in) ; ex14-3.c /* $Id: ex14-3.c,v 1.2 2004-07-12 14:40:28+09 naito Exp $ */ FILE *in, *out ; if ((in = fopen("ex14-2.c", "r")) == NULL) return -1 ; if ((out = fopen("outfile", "a")) == NULL) return -1 ; while(!feof(in)) if (fgets(buf, MAX_CHAR_PAR_LINE, in)!= NULL) fprintf(out, "%s", buf) ; fclose(out) ; fclose(in) ;

9 ex14-4.c /* $Id: ex14-4.c,v 1.2 2004-07-12 14:40:42+09 naito Exp $ */ #define MAX_CHAR (1024) char buf[max_char] ; size_t size ; FILE *in, *out ; if ((in = fopen("./a.out", "r")) == NULL) return -1 ; if ((out = fopen("./b.out", "a")) == NULL) return -1 ; while(!feof(in)) if ((size = fread((char *)buf, sizeof(char), MAX_CHAR, in))!= 0) fwrite(buf, sizeof(char), size, out) ; fclose(out) ; fclose(in) ; ex14-5.c /* $Id: ex14-5.c,v 1.2 2004-07-12 14:40:55+09 naito Exp $ */ #include <strings.h> int lines = 0, letters = 0 ; while(!feof(stdin)) if (fgets(buf, MAX_CHAR_PAR_LINE, stdin)!= NULL) lines += 1 ; letters += strlen(buf) ; printf("%d %d\n", lines, letters) ;

10 ex14-6.c /* $Id: ex14-6.c,v 1.11 2005-07-20 19:12:47+09 naito Exp $ */ #include <ctype.h> #include <stdlib.h> #define MAX (10) int read_int(char *, int *, int) ; int a[max], c, sum, i ; while(!feof(stdin)) if (fgets(buf, MAX_CHAR_PAR_LINE, stdin)!= NULL) printf("buf = %s", buf); c = read_int(buf, a, MAX) ; sum = 0 ; for(i=0;i<c;i++) sum += a[i] ; printf("result = %d\n", sum) ; int read_int(char *buf, int *a, int max) char *ps ; char s[max_char_par_line] ; int i=0 ; while((*buf)&&(i<max)) while(isspace((int)*buf)) buf++ ; /* */ if (*buf) ps = s ; while(!isspace((int)*buf)&&(*buf)) *ps++ = *buf++ ; /* */ *ps = \0 ; a[i++] = atoi(s) ; /* */ return i ;

11 ex14-7.c /* $Id: ex14-7.c,v 1.1 2005-07-19 09:32:38+09 naito Exp $ */ int i ; for(i=0;i<argc;i++) printf("%s\n", argv[i]) ;