C/C++语言 - C/C++数据

Size: px
Start display at page:

Download "C/C++语言 - C/C++数据"

Transcription

1 C/C++ C/C++

2 Table of contents char 5. 1

3

4 C = 5 (F 32). 9 F C 2

5 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ; 6 printf (" Please input the Fah temperature :\ n"); 7 scanf ("%f", & fah ); 8 cel = ( fah - 32.) * 5./9.; 9 printf (" %.2 f F = %.2 f C\n", fah, cel ); 10 return 0; 11 } 3

6 $ gcc fah2cel. c $./a. out Please input the Fahrenheit temperature : F = C 4

7 float fah, cel ; float %f %.2f scanf() %f scanf() &fah fah fah 5

8 scanf() printf() scanf() printf() 6

9

10 :

11 a b 8

12 : 9

13 : : C/C++ 9

14 # define #define 10

15 # include < stdio.h> # define PRICE 100 int main ( void ) { int num, total ; num = 10; total = num * PRICE ; printf (" total =%d\n", total ); return 0; } 11

16 # include < stdio.h> # define PRICE 100 int main ( void ) { int num, total ; num = 10; total = num * PRICE ; printf (" total =%d\n", total ); return 0; } 11

17 : 12

18 C C++ a 3 13

19

20 int signed _Bool long void _Complex short _Imaginary unsigned char float double 15

21 int long short unsigned signed char float double long double true false C _Bool C++: bool C complex C++ complex 16

22 # include < stdio.h> int main ( void ) { _Bool is_ printed = 1; if ( is_printed ) printf (" Hello world!\n"); return 0; } 17

23 # include < stdio.h> int main ( void ) { _Bool is_ printed = 1; if ( is_printed ) printf (" Hello world!\n"); return 0; } # include < iostream > using namespace std ; int main () { bool is_ printed = true ; if ( is_printed ) cout << " Hello world!" << endl ; return 0; } 17

24 1: C complex.h creal cimag conj cabs carg 18

25 # include <stdio.h> # include < complex.h> int main ( void ) { double complex a = 1 + 1I; printf ("a = (%.2f, %.2 f)\n", creal (a), cimag (a)); double complex b = conj ( a); printf ("b = (%.2f, %.2 f)\n", creal (b), cimag (b)); printf (" arg = %.5 f\n", carg (a)); printf (" abs = %.5 f\n", cabs (a)); return 0; } 19

26 2: C++ complex real imag conj abs arg 20

27 # include < cstdio > # include < complex > using namespace std ; int main ( void ) { complex < double > a (1.0, 1.0) ; printf ("a = (%.2f, %.2 f)\n", a. real (), a. imag ()); complex < double > b = conj (a); printf ("b = (%.2f, %.2 f)\n", b. real (), b. imag ()); printf (" arg = %.5 f\n", arg (a)); printf (" abs = %.5 f\n", abs (a)); return 0; } 21

28

29

30 : :

31 int int C limits.h C++ limits std::numeric_limits C 24

32 int // int_info.c # include < stdio.h> # include < limits.h> int main ( void ) { printf (" range of int is % d ~ % d\ n", INT_MIN, INT_MAX ); printf (" sizeof int = %lu bytes \n", sizeof ( int )); return 0; } 25

33 int // int_info.c # include < stdio.h> # include < limits.h> int main ( void ) { printf (" range of int is % d ~ % d\ n", INT_MIN, INT_MAX ); printf (" sizeof int = %lu bytes \n", sizeof ( int )); return 0; } $ gcc int_info.c $./a. out range of int is ~ sizeof int = 4 bytes 25

34 int // int_info. cpp # include < cstdio > # include < limits > using namespace std ; int main () { printf ( " range of int is %d ~ %d\n", numeric_limits <int >:: min (), numeric_limits <int >:: max () ); printf ( " sizeof int = %lu bytes \n", sizeof ( int ) ); return 0; } 26

35 int // int_info. cpp # include < cstdio > # include < limits > using namespace std ; int main () { printf ( " range of int is %d ~ %d\n", numeric_limits <int >:: min (), numeric_limits <int >:: max () ); printf ( " sizeof int = %lu bytes \n", sizeof ( int ) ); return 0; } $ g++ int_info. cpp $./a. out range of int is ~ sizeof int = 4 bytes 26

36 int int int var ; int var1, var2 ; int 27

37 int int 1. int n; n = 1; 2. scanf int n; scanf ("%d", &n); 3. int n = 1; 28

38 int int a = 1; int b = 2, c = 3; int d, e = 4; // valid, but not good 29

39 int 30

40 int int a; a int b=2; 2 b 3: 30

41 int // print1. c: display some properties of printf () # include < stdio.h> int main ( void ) { int a = 10; int b = 2; printf (" Doing it right : "); printf ("%d - %d = %d\n", a, b, a-b); printf (" Doing it wrong : "); printf ("%d - %d = %d\n", a); return 0; } 31

42 int // print1. c: display some properties of printf () # include < stdio.h> int main ( void ) { int a = 10; int b = 2; printf (" Doing it right : "); printf ("%d - %d = %d\n", a, b, a-b); printf (" Doing it wrong : "); printf ("%d - %d = %d\n", a); return 0; } $ gcc print1. c $./a. out Doing it right : 10-2 = 8 Doing it wrong : =

43 int print() a %d %d printf() 32

44 C 0x 0X 16 0x10 0X

45 1 // bases. c: print 100 in decimal, octal and hex 2 # include <stdio.h> 3 int main ( void ) 4 { 5 int x = 100; 6 printf (" dec = %d; oct = %o; hex = %X\n", x, x, x); 7 printf (" dec = %d; oct = %#o; hex = %#X\n", x, x, x); 8 return 0; 9 } 34

46 1 // bases. c: print 100 in decimal, octal and hex 2 # include <stdio.h> 3 int main ( void ) 4 { 5 int x = 100; 6 printf (" dec = %d; oct = %o; hex = %X\n", x, x, x); 7 printf (" dec = %d; oct = %#o; hex = %#X\n", x, x, x); 8 return 0; 9 } $ gcc bases. c $./a. out dec = 100; oct = 144; hex = 64 dec = 100; oct = 0144; hex = 0 x64 34

47 %d %o %#o %x %X %#x %#X 35

48 C/C++ 4 int short long unsigned signed short (int) %hd, %ho, %hx long (int) %ld, %lo, %lx long long (int) %lld, %llo, % llx unsigned (int) %u unsigned long (int) unsigned long long (int) %lu %llu 36

49 C/C++ 4 int short long unsigned signed short (int) %hd, %ho, %hx long (int) %ld, %lo, %lx long long (int) %lld, %llo, % llx unsigned (int) %u unsigned long (int) unsigned long long (int) %lu %llu signed short short int signed short signed short int 36

50 ? 37

51 ? CPU long int short 37

52 ? CPU long int short C/C++ short int long int 37

53 38

54 # include <stdio.h> # include <limits.h> int main ( void ) { int i = INT_MAX ; unsigned int j = UINT_ MAX ; printf ("i = %d, i+1 = %d, i+2 = %d\n", i, i+1, i +2) ; printf ("j = %u, j+1 = %u, j+2 = %u\n", j, j+1, j +2) ; return 0; } $ gcc intoverflow. c $./a. out i = , i +1 = , i +2 = j = , j +1 = 0, j +2 = 1 39

55 unsigned int 0 int

56 unsigned int 0 int

57 char

58 char : char char a, b, =, +,? char 41

59 char char char ASCII char 42

60 char char a, b; char c; A grade char grade = A ; 43

61 char char a, b; char c; A grade char grade = A ; A char grade ; // char grade = A ; // grade = A; // grade = "A"; // grade = 65; // 43

62 ASCII 44

63 ASCII char a = x ; char b = y ; x y ASCII a b a: b:

64 C/C++ 45

65 printf() %c %d ASCII 46

66 printf() %c %d ASCII // charcode. c: displays code number for a char # include <stdio.h> int main ( void ) { char c; printf (" Please input a character :\n"); scanf ("%c", &c); printf (" the code for %c is %d\n", c, c); return 0; } 46

67 printf() %c %d ASCII // charcode. c: displays code number for a char # include <stdio.h> int main ( void ) { char c; printf (" Please input a character :\n"); scanf ("%c", &c); printf (" the code for %c is %d\n", c, c); return 0; } $ gcc charcode. c $./a. out Please input a character : A 46

68 ch %c %d A 65 47

69

70 e e e e-5 48

71 C float double long double 49

72 C float double float C long double double IEEE float IEEE R32.24 double IEEE R

73 // float.c # include <stdio.h> # include <float.h> int main ( void ) { printf (" ----float ---\n"); printf (" range : %e ~ %e\n", FLT_MIN, FLT_MAX ); printf (" epsilon : %e\n", FLT_EPSILON ); printf (" size : %lu bytes \n\n", sizeof ( float )); printf (" ---- double ---\n"); printf (" range : %e ~ %e\n", DBL_MIN, DBL_MAX ); printf (" epsilon : %e\n", DBL_EPSILON ); printf (" size : %lu bytes \n\n", sizeof ( double )); printf (" ---- long double ---\n"); printf (" range : %Le ~ %Le\n", LDBL_MIN, LDBL_MAX ); printf (" epsilon : %Le\n", LDBL_EPSILON ); printf (" size : %lu bytes \n", sizeof ( long double )); return 0; } 51

74 ----float --- range : e -38 ~ e +38 epsilon : e -07 size : 4 bytes ---- double --- range : e -308 ~ e +308 epsilon : e -16 size : 8 bytes ---- long double --- range : e ~ e epsilon : e -19 size : 16 bytes 52

75 i // float. cpp # include <iostream > # include <limits > using namespace std ; int main ( void ) { cout << " ----float ----" << endl << " range : " << numeric_limits < float >:: min () << " ~ " << numeric_limits < float >:: max () << endl << " prec : " << numeric_limits < float >:: epsilon () << endl << " size : " << sizeof ( float ) << endl << endl ; cout << " ---- double ----" << endl << " range : " << numeric_limits < double >:: min () << " ~ " << numeric_limits < double >:: max () << endl << " prec : " << numeric_limits < double >:: epsilon () << endl 53

76 ii << " size : " << sizeof ( double ) << endl ; } cout << " ---- long double ----" << endl << " range : " << numeric_limits < long double >:: min () << " ~ " << numeric_limits < long double >:: max () << endl << " prec : " << numeric_limits < long double >:: epsilon () << endl << " size : " << sizeof ( long double ) << endl ; return 0; 54

77 ----float ---- range : e -38 ~ e +38 prec : e -07 size : double ---- range : e -308 ~ e +308 prec : e -16 size : long double ---- range : e ~ e prec : e -19 size : 16 55

78 1. (sign) (exponent) 3. (mantissa) 56

79 R32.24 R64.53 (120.5) 10 = ( ) 2 ( ) 2 57

80 R32.24 R64.53 (120.5) 10 = ( ) 2 ( ) n

81 24 (9) 10 = (1001) 2, 1 24 float 6 58

82

83

84 = 130 = ( ) 2 (0001) 2 60

85 = 130 = ( ) 2 (0001) =

86

87 = 133 = ( ) 2 ( ) 2 61

88 = 133 = ( ) 2 ( ) =

89 , 62

90

91 ( ) 2 = = 6 ( ) 2 = ( ) 2 =

92 // float2double. c: # include <stdio.h> int main ( void ) { float f1 = 2.2, f2 = 2.25; double g1, g2; g1 = ( double ) f1; g2 = ( double ) f2; printf ("g1 = %.13f, g2 = %.13 f\n", g1, g2); return 0; } 64

93 // float2double. c: # include <stdio.h> int main ( void ) { float f1 = 2.2, f2 = 2.25; double g1, g2; g1 = ( double ) f1; g2 = ( double ) f2; printf ("g1 = %.13f, g2 = %.13 f\n", g1, g2); return 0; } g1 = , g2 =

94

95

96

97

98

99 e E E+12, 2.87e -3 69

100 +2.87e e -3 2E // is an integer 3. e12.45e -5 70

101 1.56 E +12 // wrong double some float some = 4.0 * 2. 0; double 64 float 71

102 f F float 2.3 f 3.4 e9f l L long double l 1 L 54.3 l 4.3 E9L 72

103 // float1. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.1; if (x == 0.1) printf ("IF\n"); else if (x == 0.1 f) printf (" ELSE IF\n"); else printf (" ELSE \n"); } 73

104 // float1. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.1; if (x == 0.1) printf ("IF\n"); else if (x == 0.1 f) printf (" ELSE IF\n"); else printf (" ELSE \n"); } ELSE IF 73

105 // float1. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.1; if (x == 0.1) printf ("IF\n"); else if (x == 0.1 f) printf (" ELSE IF\n"); else printf (" ELSE \n"); } ELSE IF x f != 0.1f x == 0.1f 73

106 // float2. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.1; printf ("%lu %lu %lu\n", sizeof (x), sizeof (0.1), sizeof (0.1 f)); return 0; } 74

107 // float2. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.1; printf ("%lu %lu %lu\n", sizeof (x), sizeof (0.1), sizeof (0.1 f)); return 0; }

108 // float2. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.1; printf ("%lu %lu %lu\n", sizeof (x), sizeof (0.1), sizeof (0.1 f)); return 0; }

109 // float3. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.5; if (x == 0.5) printf ("IF\n"); else if (x == 0.5 f) printf (" ELSE IF\n"); else printf (" ELSE \n"); } 75

110 // float3. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.5; if (x == 0.5) printf ("IF\n"); else if (x == 0.5 f) printf (" ELSE IF\n"); else printf (" ELSE \n"); } IF 75

111 // float3. c: What is the output? # include < stdio.h> int main ( void ) { float x = 0.5; if (x == 0.5) printf ("IF\n"); else if (x == 0.5 f) printf (" ELSE IF\n"); else printf (" ELSE \n"); } IF x f f == 0.5f x ==

112 %f float double %e %Lf %Le long double 76

113 // showf_pt.c: # include <stdio.h> int main ( void ) { float a = ; double b = 2.14 e9; long double c = e -5; printf ("%f can be written as %e\n", a, a); printf ("%f can be written as %e\n", b, b); printf ("%Lf can be written as %Le\n", c, c); return 0; } 77

114 // showf_pt.c: # include <stdio.h> int main ( void ) { float a = ; double b = 2.14 e9; long double c = e -5; printf ("%f can be written as %e\n", a, a); printf ("%f can be written as %e\n", b, b); printf ("%Lf can be written as %Le\n", c, c); return 0; } can be written as e can be written as e can be written as e

115 # include <stdio.h> int main ( void ) { float toobig = 1 e39 ; printf (" toobig = %f\n",toobig ); return 0; } 78

116 # include <stdio.h> int main ( void ) { float toobig = 1 e39 ; printf (" toobig = %f\n",toobig ); return 0; } toobig = inf 78

117 # include <stdio.h> int main ( void ) { float toobig = 1 e39 ; printf (" toobig = %f\n",toobig ); return 0; } toobig = inf overflow C inf 78

118 # include <stdio.h> int main ( void ) { float a,b; a = 2. e20 + 1; b = a - 2. e20 ; printf ("b = %f\n", b); return 0; } 79

119 # include <stdio.h> int main ( void ) { float a,b; a = 2. e20 + 1; b = a - 2. e20 ; printf ("b = %f\n", b); return 0; } b =

120 # include <stdio.h> int main ( void ) { float a,b; a = 2. e20 + 1; b = a - 2. e20 ; printf ("b = %f\n", b); return 0; } b = e float

C C

C C C C 2017 3 8 1. 2. 3. 4. char 5. 2/101 C 1. 3/101 C C = 5 (F 32). 9 F C 4/101 C 1 // fal2cel.c: Convert Fah temperature to Cel temperature 2 #include 3 int main(void) 4 { 5 float fah, cel; 6 printf("please

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: [email protected] 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] : ,

More information

C

C C 2017 3 14 1. 2. 3. 4. 2/95 C 1. 3/95 C I 1 // talkback.c: 2 #include 3 #include 4 #define DENSITY 62.4 5 int main(void) 6 { 7 float weight, volume; 8 int size; 9 unsigned long letters;

More information

Microsoft Word - CPE考生使用手冊160524.docx

Microsoft Word - CPE考生使用手冊160524.docx 大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf (%d, & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf (%d %d 2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf (%d, & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9 201 201 21 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 1 B 1 C 5 D RPG 10 E 10 F 1 G II 1 1 201 201 C 1 # include 2 int main ( void

More information

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 [email protected] C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf(%d, &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf(% 2013 ( 28 ) ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 10 B 1 C 1 D 5 E 5 F 1 G II 5 H 30 1 2013 C 1 #include 2 int main(void) 3

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

untitled

untitled Introduction to Programming ( 數 ) Lecture 3 Spring 2005 March 4, 2005 Lecture 2 Outline 數 料 If if 狀 if 2 (Standard Output, stdout): 料. ((Standard Input, stdin): 料. 類 數 數 數 說 printf 見 數 puts 串 數 putchar

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: [email protected] 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 float candy [ 365]; char code [12]; int states [50]; 2 int array [6] = {1, 2, 4, 6, 8, 10}; 3 // day_mon1.c: # include # define MONTHS 12 int

More information

第3章.doc

第3章.doc 3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo

More information

3.1 num = 3 ch = 'C' 2

3.1 num = 3 ch = 'C' 2 Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

IO

IO 1 C/C++ C FILE* fscanf fgets fread fprintf fputs fwrite C++ ifstream ofstream >>

More information

C

C C 2017 4 1 1. 2. while 3. 4. 5. for 6. 2/161 C 7. 8. (do while) 9. 10. (nested loop) 11. 12. 3/161 C 1. I 1 // summing.c: 2 #include 3 int main(void) 4 { 5 long num; 6 long sum = 0L; 7 int status;

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: [email protected] 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

C/C++ - 字符串与字符串函数

C/C++ - 字符串与字符串函数 C/C++ Table of contents 1. 2. 3. 4. 1 char C 2 char greeting [50] = " How " " are " " you?"; char greeting [50] = " How are you?"; 3 printf ("\" Ready, go!\" exclaimed John."); " Ready, go!" exclaimed

More information

CHAPTER VC#

CHAPTER VC# 1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8 Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2 2-1 2-1.1 2-1 1 10 10!(1 10) 2-3 Visual C# 2008 10! 32767 short( )

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

Ps22Pdf

Ps22Pdf C ( CIP) C /. :, 2001. 7 21 ISBN 7-5624 -2355-5. C........ C. TP312 CIP ( 2001 ) 034496 C * * : 7871092 1 /16 : 14. 25 : 356 20017 1 20017 1 : 1 6 000 ISBN 7-5624-2355-5 / TP311 : 21. 00 C, C,,,, C,, (

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc 2 5 8 11 0 1. 13 2. 15 3. 18 1 1. 22 2. 25 3. 27 2 1. 35 2. 38 3. 41 4. 43 5. 48 6. 50 3 1. 56 2. 59 3. 63 4. 65 5. 69 13 22 35 56 6. 74 7. 82 8. 84 9. 87 10. 97 11. 102 12. 107 13. 111 4 114 1. 114 2.

More information

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha CYPOK CYPOK 1 UltraEdit Project-->Install Language Tool: Language Suite----->hi-tech picc Tool Name ---->PICC Compiler Executable ---->c:hi-picinpicc.exe ( Command-line Project-->New Project-->File Name--->myc

More information

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un Linux C July 27, 2016 Contents 1 Linux IDE 1 2 GCC 3 2.1 hello.c hello.exe........................... 5 2.2............................... 9 2.2.1 -Wall................................ 9 2.2.2 -E..................................

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 月 3 日 1 1 INPUTOUTPUT 1 InputOutput 题目描述 用 cin 输入你的姓名 ( 没有空格 ) 和年龄 ( 整数 ), 并用 cout 输出 输入输出符合以下范例 输入 master 999 输出 I am master, 999 years old. 注意 "," 后面有一个空格,"." 结束,

More information

untitled

untitled XP248 1 XP248 XP248 DCS PLC SCnet SCnet DCS SCnet DCS 1.1 XP248 Modbus HostLink Modbus XP248 4 DB25 XP248 MODBUS XP248 SCControl XP248 4 RS232 RS485 4 32 XP248 COM0-COM1 COM2-COM3 1200 19200bit/s 5 8 1

More information

数据结构与算法 - Python基础

数据结构与算法 - Python基础 Python 教材及课件 课件及作业见网址 xpzhang.me 1 1. Python 2. 3. (list) (tuple) 4. (dict) (set) 5. 6. 7. 2 Python Python 3 Python 4 Python 1, 100, -8080, 0,... 0x 0-9, a-f 0 xff00, 0 xa432bf 5 1.24, 3.14, -9.80,...

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer [email protected] 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

《C语言程序设计》教材习题参考答案

《C语言程序设计》教材习题参考答案 教 材 名 称 : C 语 言 程 序 设 计 ( 第 1 版 ) 黄 保 和 江 弋 编 著 清 华 大 学 出 版 社 ISBN: 978-7-302-13599-9, 红 色 封 面 答 案 制 作 时 间 :2011 年 2 月 -5 月 一 思 考 题 1 常 量 和 变 量 有 什 么 区 别? 它 们 分 别 是 如 何 定 义 的? 常 量 是 指 在 C 程 序 运 行 过 程 中

More information

_汪_文前新ok[3.1].doc

_汪_文前新ok[3.1].doc 普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向

More information

プログラムの設計と実現II

プログラムの設計と実現II UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

More information

C

C C 14 2017 5 31 1. 2. 3. 4. 5. 2/101 C 1. ( ) 4/101 C C ASCII ASCII ASCII 5/101 C 10000 00100111 00010000 ASCII 10000 31H 30H 30H 30H 30H 1 0 0 0 0 0 ASCII 6/101 C 7/101 C ( ) ( ) 8/101 C UNIX ANSI C 9/101

More information

FZUBRIDGE

FZUBRIDGE 1 2 3 5 8 9 10 11 12 13 14 15 16 17 19 20 21 23 24 25 29 31 32 33 34 M g1 M 1g ( M 2g M 1g )(1 e ( t, ) ) 35 36 M Q M Q g g 1.15M 1.05Q p p 37 max 1 n e max n i1 1 2 i 38 39 n max M Q M Q g g

More information

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1 21 , 7, Windows,,,, : 010-62782989 13501256678 13801310933,,,, ;,, ( CIP) /,,. : ;, 2005. 11 ( 21 ) ISBN 7-81082 - 634-4... - : -. TP316-44 CIP ( 2005) 123583 : : : : 100084 : 010-62776969 : 100044 : 010-51686414

More information

Microsoft Word - C-pgm-ws2010.doc

Microsoft Word - C-pgm-ws2010.doc Information and Communication Technology 資訊與通訊科技 Loops (while/for) C 廻路 姓名 : 班別 : ( ) CS C Programming #1 Functions 函數 : 1 若 n=14, 求以下表示式的值 Expressions 表示式 Value 值 Expressions 表示式 Value 值 A 20 2 * (n /

More information

Microsoft PowerPoint - string_kruse [兼容模式]

Microsoft PowerPoint - string_kruse [兼容模式] Strings Strings in C not encapsulated Every C-string has type char *. Hence, a C-string references an address in memory, the first of a contiguous set of bytes that store the characters making up the string.

More information

Microsoft Word - 烘焙食品乙級第二部份 doc

Microsoft Word - 烘焙食品乙級第二部份 doc 烘 焙 食 品 乙 級 技 術 士 技 能 檢 定 術 科 參 考 資 料 試 題 編 號 :077-900201-3 審 定 日 期 : 年 月 日 修 訂 日 期 :96 年 7 月 1 日 97 年 1 月 30 日 97 年 10 月 27 日 98 年 6 月 20 日 98 年 12 月 17 日 99 年 08 月 20 日 烘 焙 食 品 乙 級 技 術 士 技 能 檢 定 術 科

More information

ebook39-5

ebook39-5 5 3 last-in-first-out, LIFO 3-1 L i n e a r L i s t 3-8 C h a i n 3 3. 8. 3 C + + 5.1 [ ] s t a c k t o p b o t t o m 5-1a 5-1a E D 5-1b 5-1b E E 5-1a 5-1b 5-1c E t o p D t o p D C C B B B t o p A b o

More information

第7章-并行计算.ppt

第7章-并行计算.ppt EFEP90 10CDMP3 CD t 0 t 0 To pull a bigger wagon, it is easier to add more oxen than to grow a gigantic ox 10t 0 t 0 n p Ts Tp if E(n, p) < 1 p, then T (n) < T (n, p) s p S(n,p) = p : f(x)=sin(cos(x))

More information

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F 1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET 2.0 2.0.NET Framework.NET Framework 2.0 ( 3).NET Framework 2.0.NET Framework ( System ) o o o o o o Boxing UnBoxing() o

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7 1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7-80097 - 564-9 /TP 8 : 10. 00 ,,,, 1994 NCRE,,, ( ),,,,,

More information

untitled

untitled 1 DBF (READDBF.C)... 1 2 (filetest.c)...2 3 (mousetes.c)...3 4 (painttes.c)...5 5 (dirtest.c)...9 6 (list.c)...9 1 dbf (readdbf.c) /* dbf */ #include int rf,k,reclen,addr,*p1; long brec,erec,i,j,recnum,*p2;

More information

<4D F736F F D20B2C43032B3B920B8EAAEC6ABACBA41BB50AAEDA5DCA6A12E646F63>

<4D F736F F D20B2C43032B3B920B8EAAEC6ABACBA41BB50AAEDA5DCA6A12E646F63> C++ î Á 2-1! C Ã Ñ Ó 2-1.1! î ô à i¾ ò{î ~ à } Ñ lf ŠÈx«v ~ C ÃÑ lî nùƒ f d Û Ã ó ÎÛol ƒ à ó dîû Ê óãi Š~ v C v ÃÈxi á «constant Û Ù Ã ˆ ó nù d «12-452 100000 0 d 'A' 'Z' 8.23 0.1232 0.001 ŒÛ~ iñ C++ ó

More information

科学计算的语言-FORTRAN95

科学计算的语言-FORTRAN95 科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造

More information

z x / +/- < >< >< >< >< > 3 b10x b10x 0~9,a~f,A~F, 0~9,a~f,A~F, x,x,z,z,?,_ x,x,z,z,?,_ h H 0~9,_ 0~9,_ d D 0~7,x,X,z,Z

z x / +/- < >< >< >< >< > 3 b10x b10x 0~9,a~f,A~F, 0~9,a~f,A~F, x,x,z,z,?,_ x,x,z,z,?,_ h H 0~9,_ 0~9,_ d D 0~7,x,X,z,Z Verilog Verilog HDL HDL Verilog Verilog 1. 1. 1.1 1.1 TAB TAB VerilogHDL VerilogHDL C 1.2 1.2 C // // /* /* /* /* SYNOPSY SYNOPSY Design Compiler Design Compiler // //synopsys synopsys /* /*synopsys synopsys

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

Microsoft Word - ch04三校.doc

Microsoft Word - ch04三校.doc 4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear

More information