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

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "/* 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 */ }"

Transcription

1 C 2: A Pedestrian Approach to the C Programming Language : p- (p-adic numbers) [9, 20, 11] [20, 11] [11, 21, 22] [21] p = 16 ASCII (IME ) ASCII code i

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 */ } printf("a + b = %d\n", c); /* c 10 */ $ g++ sansu1.c $./a.out a + b = = 1500 [9] [10, 11] (0 1) C ( 2-1

3 ) ( ) C Linux OS [12] UNIX int a; int x max; float volume sphere; a = 200; a () (0 1) C = [13] 3.3 === a a = a + 1; b = 1300; c = a + b; CPU() a, b (CPU ) ( ) c CPU [9] 5 () <stdio.h> printf("a + b = %d\n", c); c %d 10 c /* a, b, c */ 2-2

4 /* */ /* 2 /* sansu2.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ printf(" a a: "); scanf("%d", &a); /* a 10 */ printf(" b b: "); scanf("%d", &b); /* b 10 */ c = a + b; /* a b c */ printf("a + b = %d\n", c); /* c 10 */ c = a - b; /* a b c */ printf("a - b = %d\n", c); /* c 10 */ c = a * b;/* a b c */ printf("a * b = %d\n", c); /* c 10 */ } c = a / b; /* a b () c */ printf("a / b = %d\n", c); /* c 10 */ $ gcc sansu2.c $./a.out a a: 1000 b b: 20 a + b =

5 a - b = 980 a * b = a / b = 50 $./a.out a a: 100 b b: 30 a + b = 130 a - b = 70 a * b = 3000 a / b = 3 () a, b () printf a a: scanf("%d", &a); a 10 1) (a, b) (b, c) c = a + b 2) a a 2 + a sansu2.c 1 [?] 2-4

6 () () (CPU) () () 1: (Central Processing Unit): : : (HDD, SSD, ) sansu2.c sansu2.c 1 () ()CPU () 1 () () int a, b, c; () 4 () printf... (), () scanf... (), ()a, b () a + b (, CPU a, b c = a + b; (, CPU () c printf("a + b = %d", c); (), () a - b (, CPUa, b c = a - b; (, CPU ( c printf("a - b = %d", c); (), () 1: 2-5

7 (i) (ii) (iii) [?] (1) CPU 1 () () (i) (CPU) () () (ii) () (iii) 2: h /* cone1.c */ #include <stdio.h> #define PI 3.14f /* PI 3.14 */ main() { float hankei, takasa, taiseki; /* hankei, takasa, taiseki */ printf(" : "); scanf("%f", &hankei); /* r */ printf(": "); scanf("%f", &takasa); /* scanf */ */ } taiseki = (1.0 / 3.0) * PI * hankei * hankei * takasa ; printf("%5.2f \n", taiseki); /* */ /* taiseki = (1.0 / 3.0) * PI * hankei * hankei * takasa ; 2-6

8 taiseki = 1 / 3 * PI * hankei * hankei * takasa ; [15] printf("%5.2f \n", taiseki); taiseki %5.2f %f %5.2f ) 2) r (r ) 3) r (r ) 4) a, h (a, h ) () /* ascii1.c */ #include <stdio.h> main() { char letter_a, letter_b; /* letter_a, letter_b */ letter_a = a ; /* letter_a a */ */ printf(" "); scanf("%c", &letter_b); /* a } printf("%c \n", letter_a); printf("%c \n", letter_b); int() float char (code) %c 2-7

9 2.2 ( int a; ) ( float hankei; ) ( double taiseki; ) ( char letter; ) 10 scanf("%d %d", &a, &b); 16 printf("a + b = %x + %x = %x", a, b, c); scanf("%f", &hankei); scanf("%lf", &taiseki); 5 printf("%5.2f", taiseki); scanf("%c", &letter); scanf("%1s", &letter); printf("hello!!!"); 3 p 1)GIMP RGB RGB GIMP 16 2)

10 : p- (p-adic numbers) p- (p-adic numbers) Kurt Hensel ( ) [16, 17]C p = 2, 8, 16 [18, 11] [19] x p > 0 x = ±a s p s +a s 1 p s 1 + +a i p i +a 0 + a 1 p + a 2 p 2 x p + + a j p j + (s = max{h : ph x }) ±a s a s 1 a i a 0.a 1 a 2 a j (2) p- (p-adic numbers) x ± a i = x x p i p p i+1 (1) (0 i s) (3) a j = x p j p x p j 1 (j = 1, 2, ) (4) (floor symbol) y y = y dd ) 2) 1) a i x p a 0 p a 1 p a 2 a 3, a 4, a 5, 2) a j x p a 1 p a 2 a 3, a 4, a 5, 2-9

11 1) 1 4 = ) 1 10 = : 1) ) (base, radix) [9, 20, 11] bit() binary digit 1 Yes or No 1 bit=2 1 1 Byte() = 8bit = 2 8 = KB() = MB() = GB() = 2 30 word() (CPU) (instruction) (size) 1 word = 8bit 16bit 32 bit 64bit 128bit x86 32 x [20, 11] 0 1 Byte( ) a b c d e f : 16 1 Byte() (2 ) = dc (16 ) = 220 (10 ) [11, 21, 22] int 4 byte(2byte) () unsigned int a; a: (= ) 2-10

12 () int a; a 2 (two s complement) 1 () [21] 1 10 = = = = = = = = x 2 e (x, e ) x() e() ()x, e float double x()5 e() 10 1) 1 10 = ) p = 16 ASCII ASCII(ANSI) ASCII=American Standard Code for Information Interchange 1963 ( 2-11

13 ANSI=Ameriacan National Standards Institute) ( )1Byte () ( ) [11] 0a Enter 0 A B a b 4: ASCII code 16 a ASCII 61 = 0x61 = JIS (ISO-2022-JP) MS (Shift JIS) 81 EUC (EUC-JP) = Extended UNIX Code UNIX( Linux ) 8 Linux UTF-8 Unicode = UTF-8 Windows Vista Unicode UTF = UCS Transfer FormatUCS = Universal Character Set [23]Windows IME 1 OS Web () OpenOffice WriterMicrosoft WordemacsFirefox Internet Explorer JIS ) [8] OS utf-8 Cygwin nkf [9] Unicode 2-12

14 2: (IME ) 2-13

15 Unicode () Web Page Web Page 1) 2) [9, 20] Windows V [1] Cygwin Linux (An Informal Introduction to Cygwin and Linux) [2] [1] 3.5 [3] [1] 4.1 [4] [1] 4.2 [5] B. W. & D. M. ( ) C 2 (The C programming Language)1989 [6] [5] 1.1 [7] L. & A. 2 (Computer Science) [8] [1] 5.5 [9] 2002 [10] [5] [11] J. May & J. Whittle ( ) Symantec C++ for Macintosh (Symantec C++ for The Macintosh) [12] D. Windows C

16 [13] C 3 (A Pedestrian Approach to the C Programming Language) [14] [1] 5.3 [15] [5] 1.2 [16] Abrégé d histoire des mathématiquesed L. Dieudonné (Hermann, Parris, 1978). [17] [17] R. Rammal, G. Toulouse and M. A. Virasoro, Rev. Mod. Phys. 58, (1986). [18] [5] pp 45-6 pp [19] S. & J : 2 [20] 2003 [21] [22] [23] Linux (2000 ) 6.1 c 2014 Masao Matsumoto 2-15