: (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49
[P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : <, >, <=, >=, ==,!= [P.69] [P.70] [P.71] 50
(Data type) ( ) :,... (Bit) ( ) ( ) 0 1 51
C (bytes) (Integer) int 4* 32 (Long Integer) long 4* 32 (Long Long Integer) long long 8 32 (Character) char 1 ʻaʼ (Single Precision Floating Point) (Double Precision Floating Point) float 4 4.39 double 8 4.39 void?? sizeof() 52
; int num; = ; int num = 0; (keywords) num (int) 0 2293620 ( ) C ( ) auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while 53
sizeof sizeof() (Bytes) [1 Byte = 8 Bits] sizeof.cpp 32-bit long 4 bytes 64-bit long 8 bytes 54
(int) (char) (int) (float) (int) (long long) (float) (double) ( ) (int) (unsigned int) 55
Bit (0 1) Byte 8 Bit Byte 2 8 = 256 ( [signed]) -128 127 ( 256 ) [unsigned] 0 255 4 Byte : 2 8x4 = 2 32 = 4,294,967,296 4 Byte int 2,147,483,648 2,147,483,647 ( ) 4 Byte unsigned int 0 4,294,967,295 ( ) 56
(int) 32 bit (4 bytes) 2 : 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 256 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2147483647 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1-2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0-255 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1-2147483648 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 57
(floating point) IEEE (1 Bit),, 7707 0 0 0 1 1 1 1 0 0 0 0 1 1 0 1 1 0 0 0 1 1 1 1 0 0 0 0 1 1 0 1 1 ) ) ) [ ] + 3 1563 + 0.1563 10 3 float 7 double 15 ( http://goo.gl/imxgf 58
printf scanf (Integer) int %d (Long Integer) long %ld (Long Long Integer) long long %lld %I64d (Character) char %c (Single Precision Floating Point) (Double Precision Floating Point) float %f double %f, %lf printf scanf 59
(calc.cpp) (calc_1.cpp) ( ) : : float scanf %f float printf %f float printf %.3f 60
3 (Integer) int 3. (Double Precision Floating Point) 3.f (Single Precision Floating Point) double float 3 (Character) char constant.cpp 61
( ) ( ) : 4 / 3 4 / 3. 4 / 3 int 4 / 3. 4 int 3. double 4 double 3. double ( ) (double) 4 / 3 4 double ( 4. ) 3 3 double ( 3.) double 62
casting.cpp casting.cpp A = B B A B A B A printf scanf : printf( %d, 3.); 3. double int printf scanf 63
(bignum) int log(2 31 ) ~ 9.3 long long log(2 63 ) ~ 19.0 Dev C++ %I64d long long 64
char (ASCII ) ( ) ASCII A +1? (char) (int)(???) A -1? (char) (int)(???) A + 1? (char)(char)(???) [ ] char int char.cpp 65
(tolower) char input =?; char output = input - A + a ; : A : a : B : b : Z : z 66
: +-*/% (*/% +- ) A = 3 * ( 2 + 1 ) + 7 / 2 + 9 * 3.; A = 3 * 3 + 7 / 2 + 9 * 3.; A = 9 + 7 / 2 + 9 * 3.; A = 9 + 3 + 9 * 3.; A = 9 + 3 + 27. ; A = 12 + 27. ; A = 39. ; 67
: = = (=) ( ) int A,B; double C, D; A = 3; 3 = A; A = B = 3; A = C = B = D = 3 + 7 / 2. ; assign.cpp 68
0 0 0 1 2-1 69
0 0 0 ( ) 0 ( ) > < ( ) >= ( ) <= == 4 > 3 4 < 3 4 == 3 4!= 3 4 > 3 > 2!= 70
0 0 0 ( ) 0 ( ) C and or (and) && (or) (not)! 1 && 1 1 && 0 1 1 1 0 4 > 3 && 3 > 2 4 > 3 && 4 < 3 4 > 3 4 < 3!1 71
( )! * / % + - < > <= >= ==!= = && 72
if... if ( ) {... }... if (80 >= 60) { printf( PASSED!\n ); } if (80 < 60) { printf( FAILED!\n ); } int grade = 80; if (grade >= 60) { printf( PASSED!\n ); } if (grade < 60) { printf( FAILED!\n ); } 73
(cmp) : : 3 : 4 : 4 : ( ) int max; if (num1 >= num2) { max = num1; } if (num1 < num2) { max = num2; } printf( %d\n, max); 74
(guess) : 3 : 5 : 4 75
Bitwise AND & Bitwise OR Bitwise XOR ^ Bitwise NOT ~ Bitwise Left Shift << Bitwise Right Shift >> 76
(1) [E0201] double x = 3000000000000000.5; [E0202]* 3000000000000000.5+0.05 [E0203] ( ) [ = * 1.6] [E0204] 129263*54628 [E0110] [E0205]* 1292635428 (2159872744519190546127922752) 77
(2) [E0206] (>=0) (< 0) [E0207] (0-9) (a-za-z) (char) scanf %c printf %c [E0208] [E0209] ( ) 78
(3) [E0210] : 3 6 : 3 6 : 6 3 : 3 6 [E0211] : 38603456 3 8 6 0 3 4 5 6 79
(4) [E0213] ( ) : (A: 10, B:11, C:12,..., Z:36) %c%d A 1 2 3 4 5 6 7 8 1 0 1 2 3 4 5 6 7 8 x1 x9 x8 x7 x6 x5 x4 x3 x2 x1 = 1x1 + 0x9 + 1x8 + 2x7 + 3x6 + 4x5 + 5x4 + 6x3 + 7x2 + 8x1 = 121 121%10 = 1, (10-1)%10 = 9 80