C 语言 第七讲 分支 张晓平 武汉大学数学与统计学院 2017 年 4 月 5 日

Size: px
Start display at page:

Download "C 语言 第七讲 分支 张晓平 武汉大学数学与统计学院 2017 年 4 月 5 日"

Transcription

1 C 语言 第七讲 分支 张晓平 武汉大学数学与统计学院 2017 年 4 月 5 日

2 1. if 语句 2. if else 语句 3. 获取逻辑性 4. 一个统计字数的程序 5. 条件运算符 6. continue 和 break 语句 2/145 C 语言

3 7. switch 语句 8. goto 语句 3/145 C 语言

4 1. if 语句

5 if 语句 I 1 // colddays.c: 2 #include <stdio.h> 3 int main(void) 4 { 5 const int FREEZING = 0; 6 float temperature; 7 int cold_days = 0; 8 int all_days = 0; 9 printf("enter the list of daily low temperature.\n"); 10 printf("use Celsius, and enter q to quit.\n"); 11 while (scanf("%f", &temperature)==1) { 12 all_days++; 13 if (temperature < FREEZING) 14 cold_days++; 5/145 C 语言

6 if 语句 II 15 } 16 if (all_days!= 0) 17 printf("%d days total: %.1f%% below freezing.\n", 18 all_days, 100.0*(float)cold_days/ all_days); 19 if (all_days == 0) 20 printf("no data entered.\n"); 21 return 0; 22 } 6/145 C 语言

7 if 语句 Enter the list of daily low temperature. Use Celsius, and enter q to quit q 10 days total: 40.0% were below freezing. 7/145 C 语言

8 if 语句 if 语句被称为分支语句, 其一般形式为 if (condition) statement if (condition){ statements } 若 condition 的值为真, 则执行 statements; 否则跳过该语句 if 结构和 while 结构相似, 主要区别在于, 在 if 结构中, 判断和执行仅有一次, 而在 while 结构中, 判断和执行可以重复多次 8/145 C 语言

9 if 语句 condition 是一个关系表达式, 通常是比较两个量的大小 更一般地,condition 可以是任何表达式, 其值为 0 就被视为假 语句部分可以是一条简单语句, 也可以是一个由花括号括起的复合语句 : if (score >= 60) printf("pass!\n"); if (a > b){ a++; printf("you lose. b.\n"); } 9/145 C 语言

10 2. if else 语句

11 if else 语句 if (condition) statement1 else statement2 11/145 C 语言

12 if else 语句 if (condition) statement1 else statement2 若满足条件 (condition 为真 ), 则执行 statement1; 若不满足条件 (condition 为假 ), 则执行 statement2 语句可以是简单语句或复合语句 注意缩进 11/145 C 语言

13 if else 语句 若 if 和 else 之间有多条语句, 必须使用花括号 // wrong structure if (x > 0) printf("incrementing x:\n"); x++; else printf("x <= 0\n"); 12/145 C 语言

14 if else 语句 若 if 和 else 之间有多条语句, 必须使用花括号 // wrong structure if (x > 0) printf("incrementing x:\n"); x++; else printf("x <= 0\n"); 编译器会把 printf 语句看做 if 的一部分, 而把 x++; 看做是一条单独的语句, 而不是 if 的一部分 然后认为 else 没有对应的 if, 于是报错 12/145 C 语言

15 if else 语句 // right structure if (x > 0){ printf("incrementing x:\n"); x++; } else printf("x <= 0\n"); 13/145 C 语言

16 if else 语句 if num > 10 no yes num *= 2; printf("%d\n", num); 14/145 C 语言

17 if else 语句 if else num > 10 yes printf("%d\n", num); num *= 2; 15/145 C 语言

18 getchar 与 putchar 函数 函数 getchar 没有参数, 返回来自输入设备的下一个字符 ch = getchar() ; scanf("%c", &ch); 函数 putchar 打印它的参数 putchar(ch); printf("%c", ch); 16/145 C 语言

19 getchar 与 putchar 函数 只处理字符, 比函数 scanf 和 printf 更快更简洁 不需要格式说明符 在 stdio.h 中定义 事实上, 它们只是宏定义, 不是真正的函数 17/145 C 语言

20 getchar 与 putchar 函数 1 // cypher1.c 2 #include <stdio.h> 3 #define SPACE 4 int main(void) 5 { 6 char ch; 7 ch = getchar(); 8 while (ch!= \n ) { 9 if (ch == SPACE) 10 putchar(ch); 11 else 12 putchar(ch+1); 13 ch = getchar(); 14 } 15 putchar(ch); 16 return 0; 17 } 18/145 C 语言

21 getchar 与 putchar 函数 1 // cypher1.c 2 #include <stdio.h> 3 #define SPACE 4 int main(void) 5 { 6 char ch; 7 ch = getchar(); 8 while (ch!= \n ) { 9 if (ch == SPACE) 10 putchar(ch); 11 else 12 putchar(ch+1); 13 ch = getchar(); 14 } 15 putchar(ch); 16 return 0; 17 } Hello World Ifmmp Xpsme 18/145 C 语言

22 getchar 与 putchar 函数 ch = getchar(); while (ch!= \n ) {... ch = getchar(); } 可改写为 while ((ch = getchar())!= \n ) {... } 19/145 C 语言

23 getchar 与 putchar 函数 ch = getchar(); while (ch!= \n ) {... ch = getchar(); } 可改写为 while ((ch = getchar())!= \n ) {... } 这体现了典型的 C 编程风格 : 将两个动作合并为一个表达式 19/145 C 语言

24 getchar 与 putchar 函数 更建议写成 while ( (ch = getchar())!= \n ) {... } 20/145 C 语言

25 getchar 与 putchar 函数 两个动作 : 将某个值赋给 ch, 并将这个值与换行符作比较 圆括号使 ch = getchar() 称为!= 的左操作数 先调用函数 getchar, 将其返回值赋给 ch 而赋值表达式的值等于左操作数的值, 故 ch = getchar() 的值等于 ch 的值 最后将 ch 与换行符做比较 21/145 C 语言

26 getchar 与 putchar 函数 圆括号是必须的 若写成 while ( ch = getchar()!= \n ) {... } 首先会计算表达式 getchar()!= \n, 其值为 0 或 1, 然后这个值被赋给 ch 于是 ch 将会被赋为 0 或 1, 而不是 getchar 的返回值 22/145 C 语言

27 ctype.h: 字符函数 1 // cypher2.c 2 #include <stdio.h> 3 #include <ctype.h> 4 int main(void) 5 { 6 char ch; 7 while ((ch = getchar())!= \n ) { 8 if (isalpha(ch)) 9 putchar(ch+1); 10 else 11 putchar(ch); 12 } 13 putchar(ch); 14 return 0; 15 } 23/145 C 语言

28 ctype.h: 字符函数 Look! It s a programmer! Mppl! Ju t b qsphsbnnfs! 24/145 C 语言

29 ctype.h: 字符函数 表 : 字符判断函数 函数名 isalnum isalpha 为如下参数时, 返回值为真字母或数字 字母 isblank 标准空白字符 ( 空格 水平制表符或换行符 ) iscntrl isdigit isgraph 控制符, 如 Ctrl+B 阿拉伯数字 除空格字符之外的所有可打印字符 25/145 C 语言

30 ctype.h: 字符函数 表 : 字符判断函数 函数名 islower isprint ispunct isspace isupper isxdigit 为如下参数时, 返回值为真小写字母 可打印字符 标点符号 空白字符 : 空格 换行 水平 ( 垂直 ) 制表符 回车 大写字母 十六进制数字字符 26/145 C 语言

31 ctype.h: 字符函数 表 : 字符映射函数 函数名 动作 tolower 若参数为大写字母, 则返回相应的小写字母 ; 否则返回原始参数 toupper 若参数为小写字母, 则返回相应的大写字母 ; 否则返回原始参数 27/145 C 语言

32 ctype.h: 字符函数 字符映射函数不改变原始参数, 只返回改变后的值 也就是说, 以下语句不改变 ch 的值 tolower(ch); 若想改变 ch, 可使用 ch = tolower(ch); 28/145 C 语言

33 多重选择 else if 例某电力公司的费率如下 : 第一个 360kwh 下一个 320kwh 超过 680kwh $ /kwh $ /kwh $ /kwh 编制程序, 计算你的用电费用 29/145 C 语言

34 多重选择 else if I 1 // electric.c 2 #include <stdio.h> 3 #define RATE #define RATE #define RATE #define BREAK #define BREAK #define BASE1 (RATE1 * BREAK1) 9 #define BASE2 (BASE1 + RATE2 * (BREAK2 - BREAK1) ) 10 int main(void) 11 { 12 double kwh, bill; 13 printf("please enter the kwh used.\n"); 14 scanf("%lf", &kwh); 30/145 C 语言

35 多重选择 else if II 15 if (kwh <= BREAK1) 16 bill = RATE1 * kwh; 17 else if (kwh <= BREAK2) 18 bill = BASE1 + RATE2 * (kwh - BREAK1); 19 else 20 bill = BASE2 + RATE3 * (kwh - BREAK2); 21 printf("the charge for %.1f kwh is $%.2f.\n", 22 kwh, bill); 23 return 0; 24 } 31/145 C 语言

36 多重选择 else if Please enter the kwh used. 580 The charge for kwh is $ /145 C 语言

37 多重选择 else if if else if kwh<=break1 else bill=base2+ RATE3* (kwh-break2); kwh<=break2 yes bill=base1+ RATE2* (kwh-break1); yes bill=rate1*kwh 33/145 C 语言

38 多重选择 else if if (kwh <= BREAK1) bill = RATE1 * kwh; else if (kwh <= BREAK2) bill = BASE1 + RATE2 * (kwh - BREAK1); else bill = BASE2 + RATE3 * (kwh - BREAK2); 等价于 if (kwh <= BREAK1) bill = RATE1 * kwh; else if (kwh <= BREAK2) bill = BASE1 + RATE2 * (kwh - BREAK1); else bill = BASE2 + RATE3 * (kwh - BREAK2); 34/145 C 语言

39 多重选择 else if 第二种形式是 if else 语句的嵌套 因整个 if else 结构是一条语句, 故第一个 else 后面不需要用花括号 虽然两种形式完全等价, 但建议采用第一种形式, 它可以更清晰地展示出有三种选择 35/145 C 语言

40 多重选择 else if 可以把多个所需的 else if 语句连成一串使用 if (score < 1000) bonus = 0; else if (score < 1500) bonus = 1; else if (score < 2000) bonus = 2; else if (score < 2500) bonus = 3; else bonus = 4; 编译器对嵌套层数有限制,C99 标准要求编译器最少支持 127 层嵌套 36/145 C 语言

41 else 与 if 的配对 1 // elseif.c: 2 #include <stdio.h> 3 int main(void) 4 { 5 int number; 6 printf("enter an integer: "); 7 scanf("%d", &number); 8 if (number > 6) 9 if (number < 12) 10 printf("you re close!\n"); 11 else 12 printf("sorry, you loose a turn!\n"); 13 return 0; 14 } 37/145 C 语言

42 else 与 if 的配对 Enter an integer: 5 38/145 C 语言

43 else 与 if 的配对 Enter an integer: 5 Enter an integer: 10 You re close! 38/145 C 语言

44 else 与 if 的配对 Enter an integer: 5 Enter an integer: 10 You re close! Enter an integer: 15 Sorry, you loose a turn! 38/145 C 语言

45 else 与 if 的配对 规则 如果没有花括号,else 与和它最近的一个 if 相匹配 39/145 C 语言

46 else 与 if 的配对 上例最好改写为 if (number > 6) if (number < 12) printf("you re close!\n"); else printf("sorry, you loose a turn!\n"); 40/145 C 语言

47 else 与 if 的配对 若真的希望 else 和第一个 if 匹配, 请写成 if (number > 6) { if (number < 12) printf("you re close!\n"); } else printf("sorry, you loose a turn!\n"); 41/145 C 语言

48 多层嵌套的分支结构 例编写程序, 由用户输入一个整数, 然后判断其是否为质数 如果不是质数, 请求出其公约数 42/145 C 语言

49 多层嵌套的分支结构 I 1 #include <stdio.h> 2 #include <stdbool.h> 3 int main(void) 4 { 5 unsigned long num; 6 unsigned long div; 7 bool isprime; 8 9 printf("enter an integer "); 10 printf("(enter q to quit).\n"); 11 while (scanf("%lu", &num) == 1) { 12 for (div = 2, isprime = true; 13 div * div <= num; 14 div++) { 15 if (num % div == 0) { 43/145 C 语言

50 多层嵌套的分支结构 II 16 if (div * div!= num) 17 printf("%lu is divisible by %lu and % lu.\n", 18 num, div, num / div); 19 else 20 printf("%lu is divisible by %lu.\n", 21 num, div); 22 isprime = false; 23 } 24 } 25 if (isprime) 26 printf("%lu is prime.\n", num); 27 printf("enter another integer "); 28 printf("(enter q to quit).\n"); 29 } 30 printf("bye.\n"); 44/145 C 语言

51 多层嵌套的分支结构 III return 0; 33 } 45/145 C 语言

52 多层嵌套的分支结构 I Enter an integer (Enter q to quit) is divisible by 2 and is divisible by 3 and is divisible by 4 and is divisible by 6. Enter another integer (Enter q to quit) is prime. Enter another integer (Enter q to quit) is divisible by 3 and Enter another integer (Enter q to quit). q Bye. 46/145 C 语言

53 3. 获取逻辑性

54 获取逻辑性 例编写程序, 首先输入一个句子, 然后计算除单引号和双引号意外的字符出现的次数 48/145 C 语言

55 获取逻辑性 1 // chcount.c: 2 #include <stdio.h> 3 #define PERIOD. 4 int main(void) 5 { 6 int ch; 7 int charcount = 0; 8 while ((ch = getchar())!= PERIOD) { 9 if (ch!= " && ch!= \ ) 10 charcount++; 11 } 12 printf("there are %d non-quote characters.\n", charcount); 13 return 0; 14 } 49/145 C 语言

56 获取逻辑性 "I m fine". There are 7 non-quote characters. 50/145 C 语言

57 获取逻辑性 首先, 程序读入一个字符并检查它是不是一个句号 接下来的语句中, 使用了逻辑与运算符 && 此时,if 语句的含义为 若字符不是双引号也不是单引号, 则 charcount 增加 1 要使整个表达式为真, 则两个条件都必须为真 逻辑运算符的优先级低于关系运算符, 故不必使用圆括号 51/145 C 语言

58 获取逻辑性 表 : 逻辑运算符 运算符 含义 && 与 或! 非 52/145 C 语言

59 获取逻辑性 设 exp1 和 exp2 为两个简单的关系表达式, 则 仅当 exp1 和 exp2 都为真时,exp1 && exp2 才为真 若 exp1 或 exp2 为真或二者都为真, exp1 exp2 为真 若 exp1 为假, 则!exp1 为真 ; 若 exp1 为真, 则!exp1 为假 53/145 C 语言

60 获取逻辑性 请判断以下表达式的值 5 > 2 && 4 > 7 5 > 2 4 > 7! (4 > 7) 54/145 C 语言

61 头文件 iso646.h C99 标准为逻辑运算符增加了可供选择的拼写法, 它们在头文件 iso646.h 中定义 若包含了该头文件, 可用 and 代替 &&, 用 or 代替, 用 not 代替! 55/145 C 语言

62 头文件 iso646.h 若包含了头文件 iso646.h, 则 if (ch!= " && ch!= \ ) charcount++; 可重写为 if (ch!= " and ch!= \ ) charcount++; 56/145 C 语言

63 头文件 iso646.h 表 : 逻辑运算符的可选表示法传统用法 iso646.h && and or! not 57/145 C 语言

64 优先级 逻辑非运算符! 为单目运算符, 优先级同增量运算符相同, 仅次于圆括号 && 的优先级高于, 两者的优先级都低于关系运算符, 高于赋值运算符 如 a > b && b > c b > d 会被视为 ((a > b) && (b > c)) (b > d) 58/145 C 语言

65 求值顺序 除了那些两个运算符共享一个操作数的情况外,C 通常不保证复杂表达式的哪个部分首先被求值 如以下语句中 b = (5 + 3) * (9 + 6) 可能先计算 的值, 也可能先计算 的值 C 允许这种不确定性, 以便编译器设计者可以针对特定系统做出最有效率的选择 59/145 C 语言

66 求值顺序 但对逻辑运算符的处理是个例外,C 保证逻辑表达式是从左到右求值的 && 和 是顺序点, 故在程序从一个操作数前进到下一个操作数之前, 所有副作用都会生效 C 保证一旦发现某个元素使表达式总体无效, 求值会立即停止 60/145 C 语言

67 求值顺序 while ((c = getchar())!= && c!= \n ) 61/145 C 语言

68 求值顺序 while ((c = getchar())!= && c!= \n ) 该结构用于循环读入字符, 直到出现第一个空格符或换行符 第一个子表达式给 c 赋值, 然后该值用于第二个子表达式中 若没有顺序保障, 计算机可能试图在 c 被赋值之前判断第二个表达式 61/145 C 语言

69 求值顺序 while (x++ < 10 && x + y < 20) 62/145 C 语言

70 求值顺序 while (x++ < 10 && x + y < 20) && 是顺序点, 故保证了在对右边表达式求值之前, 先把 x 的值增加 1 62/145 C 语言

71 求值顺序 if (number!= 0 && 12/number == 2) printf("the number is 5 or 6.\n"); 63/145 C 语言

72 求值顺序 if (number!= 0 && 12/number == 2) printf("the number is 5 or 6.\n"); 若 number 值为 0, 则第一个表达式为假, 就不再对关系表达式求值 这就避免了计算机试图把 0 作为除数 63/145 C 语言

73 范围 可把 && 用于测试范围 如要检查 90 到 100 范围内的得分, 可以这样做 if (score >= 90 && score <= 100) printf("excellent!\n"); 64/145 C 语言

74 范围 可把 && 用于测试范围 如要检查 90 到 100 范围内的得分, 可以这样做 if (score >= 90 && score <= 100) printf("excellent!\n"); 64/145 C 语言

75 范围 请避免以下做法 : if (90 <= score <= 100) printf("excellent!\n"); 65/145 C 语言

76 范围 请避免以下做法 : if (90 <= score <= 100) printf("excellent!\n"); 这段代码没有语法错误, 但有语义错误 因对 <= 运算符的求值顺序是从左到右的, 故测试表达式会被解释为 (90 <= score) <= 100 而子表达式 90 <= score 的值为 1 或 0, 总小于 100 故不管 range 取何值, 整个表达式总为真 65/145 C 语言

77 4. 一个统计字数的程序

78 一个统计字数的程序 编制程序, 读取一段文字, 并报告其中的单词个数, 同时统计字符个数和行数 67/145 C 语言

79 一个统计字数的程序 该程序应该逐个读取字符, 并想办法判断何时停止 应该能够识别并统计字符 行和单词 68/145 C 语言

80 一个统计字数的程序 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read, increment line count 6 if a word has been read, increment word count 7 read next character 69/145 C 语言

81 一个统计字数的程序 // 循环输入结构 while ((ch = getchar())!= STOP) {... } 70/145 C 语言

82 一个统计字数的程序 // 循环输入结构 while ((ch = getchar())!= STOP) {... } 在通用的单词统计程序中, 换行符和句号都不适合标记一段文字的结束 我们将采用一个不常见的字符 70/145 C 语言

83 一个统计字数的程序 程序使用 getchar 来循环输入字符, 可在每次循环通过递增一个字符计数器的值来统计字符 为统计行数, 程序可检查换行符 若字符为换行符, 程序就递增行数计数器的值 若 STOP 字符出现在一行的中间, 则将该行作为一个不完整行来统计, 即该行有字符但没有换行符 71/145 C 语言

84 一个统计字数的程序 如何识别单词? 72/145 C 语言

85 一个统计字数的程序 如何识别单词? 可将一个单词定义为不包含空白字符的一系列字符 一个单词以首次遇到非空白字符开始, 在下一个空白字符出现时结束 72/145 C 语言

86 一个统计字数的程序 检测非空白字符的判断表达式为 c!= && c!= \n && c!= \t 或!isspace(c) // #include <ctype.h> 检测空白字符的判断表达式为 c == c == \n c == \t 或 isspace(c) // #include <ctype.h> 73/145 C 语言

87 一个统计字数的程序 为了判断一个字符是否在某个单词中, 可在读入一个单词的首字符时把一个标志 ( 命名为 inword) 设置为 1, 同时在此处递增单词个数 只要 inword 为 1, 后续的非空白字符就不标记为一个单词的开始 到出现下一个空白字符时, 就把 inword 设置为 0 1 // pseudo code 2 if c is not a whitespace and inword is false 3 set inword to true and count the word 4 if c is a white space and inword is true 5 set inword to false 74/145 C 语言

88 一个统计字数的程序 I 1 // wordcnt.c: 2 #include <stdio.h> 3 #include <ctype.h> 4 #include <stdbool.h> 5 #define STOP 6 int main(void) 7 { 8 char c; 9 char prev; 10 long n_chars = 0L; 11 int n_lines = 0; 12 int n_words = 0; 13 int p_lines = 0; 14 bool inword = false; 15 printf("enter text ( to quit):\n"); 75/145 C 语言

89 一个统计字数的程序 II 16 prev = \n ; 17 while ((c = getchar())!= STOP) { 18 n_chars++; 19 if (c == \n ) 20 n_lines++; 21 if (!isspace(c) &&!inword) { 22 inword = true; 23 n_words++; 24 } 25 if (isspace(c) && inword) 26 inword = false; 27 prev = c; 28 } 29 if (prev!= \n ) 30 p_lines = 1; 76/145 C 语言

90 一个统计字数的程序 III 31 printf("characters = %ld, words = %d, lines = %d, ", n_chars, n_words, n_lines); 32 printf("partial lines = %d\n", p_lines); 33 return 0; 34 } 77/145 C 语言

91 一个统计字数的程序 Enter text ( to quit): Reason is a powerful servant but an inadequate master. characters = 56, words = 9, lines = 3, partial lines = 0 78/145 C 语言

92 5. 条件运算符

93 条件运算符 C 提供一种简写方式来表示 if else 语句, 被称为条件表达式, 并使用条件运算符 (? :) 它是 C 语言中唯一的三目操作符 80/145 C 语言

94 条件运算符 x = (y < 0)? -y : y; 求绝对值 81/145 C 语言

95 条件运算符 x = (y < 0)? -y : y; 求绝对值 含义 : 若 y 小于 0, 则 x = -y; 否则,x = y 用 if else 描述为 if (y < 0) x = -y; else x = y; 81/145 C 语言

96 条件运算符 条件表达式的语法 expresion1? expression2 : expression3 82/145 C 语言

97 条件运算符 条件表达式的语法 expresion1? expression2 : expression3 若 expresion1 为真, 则条件表达式的值等于 expression2 的值 ; 若 expresion1 为假, 则条件表达式的值等于 expression3 的值 82/145 C 语言

98 条件运算符 若希望将两个可能的值中的一个赋给变量时, 可使用条件表达式 典型的例子是将两个值中的最大值赋给变量 : max = (a > b)? a : b; 83/145 C 语言

99 条件运算符 if else 语句能完成与条件运算符同样的功能 但是, 条件运算符语句更简洁 ; 并且可以产生更精简的程序代码 84/145 C 语言

100 条件运算符 例设每罐油漆可喷 200 平方英尺, 编写程序计算向给定的面积喷油漆, 全部喷完需要多少罐油漆 85/145 C 语言

101 条件运算符 1 // paint.c: 2 #include <stdio.h> 3 #define COVERAGE int main(void) 5 { 6 int sq_feet, cans; 7 printf("enter number of square feet to be painted:\n"); 8 while (scanf("%d", &sq_feet)) { 9 cans = sq_feet / COVERAGE; 10 cans += (sq_feet % COVERAGE == 0)? 0 : 1; 11 printf("you need %d %s of paint.\n", 12 cans, cans == 1? "can" : "cans"); 13 printf("enter next value (q to quit):\n"); 14 } 15 return 0; 16 } 86/145 C 语言

102 条件运算符 Enter number of square feet to be painted: 200 You need 1 can of paint. Enter next value (q to quit): 225 You need 2 cans of paint. Enter next value (q to quit): q 87/145 C 语言

103 6. continue 和 break 语句

104 continue 和 break 语句 continue 和 break 语句用于循环结构, 根据判断条件来忽略部分循环甚至终止循环 89/145 C 语言

105 continue 和 break 语句 :continue 语句 当程序运行到 continue 语句时, 其后的内容将被忽略, 开始进入下一次循环 当 continue 语句用于嵌套结构时, 仅影响包含它的那一层循环 90/145 C 语言

106 continue 和 break 语句 :continue 语句 例输入 之间的多个分数, 求其平均分 最低分和最高分 当输入分数不在 之间时, 程序应该不做处理 91/145 C 语言

107 continue 和 break 语句 :continue 语句 I 1 #include <stdio.h> 2 int main(void) 3 { 4 const float MIN = 0.0f; 5 const float MAX = 100.0f; 6 7 float score; 8 float total = 0.0f; 9 int n = 0; 10 float min = MIN; 11 float max = MAX; printf("enter the first score (q to quit): "); 14 while (scanf("%f", &score) == 1) 15 { 92/145 C 语言

108 continue 和 break 语句 :continue 语句 II 16 if (score < MIN score > MAX) 17 { 18 printf("%.1f is invalid.try again: ", score); 19 continue; 20 } 21 printf("accepting %.1f:\n", score); 22 min = (score < min)? score : min; 23 max = (score > min)? score : max; 24 total += score; 25 n++; 26 printf("enter next score (q to quit): "); 27 } 28 if (n > 0) 29 { 93/145 C 语言

109 continue 和 break 语句 :continue 语句 III 30 printf("average of %d scores is %.1f.\n", n, total/n); 31 printf("low = %.1f, High = %.1f.\n", min, max); 32 } 33 else 34 printf("no valid scores were entered.\n"); return 0; 37 } 94/145 C 语言

110 continue 和 break 语句 :continue 语句 Enter the first score (q to quit): 20 Accepting 20.0: Enter next score (q to quit): is invalid. Try again: 30 Accepting 30.0: Enter next score (q to quit): is invalid. Try again: q Average of 2 scores is Low = 0.0, High = /145 C 语言

111 continue 和 break 语句 :continue 语句 对于 while 和 do while 循环,continue 语句之后发生的动作是求循环表达式的值 而对于 for 循环, 下一个动作是先求更新表达式的值, 然后再求判断表达式的值 96/145 C 语言

112 continue 和 break 语句 :continue 语句 count = 0; while (count < 10) { ch = getchar(); if (ch == \n ) continue; putchar(ch); count++; } 读取除换行符外的 10 个字符, 并回显它们 注意 : 换行符不会被计数 97/145 C 语言

113 continue 和 break 语句 :continue 语句 for (count = 0; count < 10; count++) { ch = getchar(); if (ch == \n ) continue; putchar(ch); } 读取包含换行符在内的 10 个字符, 换行符不被回显, 但会被计数 98/145 C 语言

114 continue 和 break 语句 :break 语句 当程序运行到 break 语句时, 将会终止包含它的循环, 跳出该循环体 当 break 语句用于嵌套结构时, 仅影响包含它的那一层循环 99/145 C 语言

115 continue 和 break 语句 :break 语句 例输入矩形的长和宽, 用一个循环来计算其面积 若输入一个非数字作为矩形的长或宽, 终止循环 100/145 C 语言

116 continue 和 break 语句 :break 语句 I 1 #include <stdio.h> 2 int main(void) 3 { 4 float length, width; 5 printf("enter the length of the rectangle: "); 6 7 while (scanf("%f", &length) == 1) { 8 printf("length = %.2f.\n", length); 9 printf("enter its width: "); 10 if (scanf("%f", &width)!= 1) 11 break; 12 printf("width = %.2f;\n", width); 13 printf("area = %.2f; \n", length * width); 14 printf("enter the length of the rectangle: " ); 101/145 C 语言

117 continue 和 break 语句 :break 语句 II 15 } 16 printf("done.\n"); 17 return 0; 18 } 102/145 C 语言

118 continue 和 break 语句 :continue 语句 Enter the length of the rectangle: 10 Length = Enter its width: 20 Width = 20.00; Area = ; Enter the length of the rectangle: 10 Length = Enter its width: q Done. 103/145 C 语言

119 continue 和 break 语句 :break 语句 break 语句使程序直接跳转到该循环后的第一条语句 ; 在 for 循环中, 更新表达式也将被跳过 嵌套循环中,break 语句只能使程序跳出当前循环, 要跳出外层循环还需另外一个 break 语句 104/145 C 语言

120 continue 和 break 语句 :break 语句 int p, q; scanf("%d", &p); while (p > 0) { printf("%d\n", p); scanf("%d", &q); while (q > 0) { printf("%d\n", p*q); if (q > 100) break; scanf("%d", &q); } if (q > 100) break; scanf("%d", &p); } 105/145 C 语言

121 7. switch 语句

122 switch 语句 多重选择时, 可以使用 if (condition1)... else if (condition2)... else if (condition3)... else 但多数情况下, 使用 switch 语句会更加方便 107/145 C 语言

123 switch 语句 I 1 // animals.c 2 #include <stdio.h> 3 #include <ctype.h> 4 int main(void) 5 { 6 char ch; 7 printf("give a letter, and I will give you an "); 8 printf("animal name beginning with that letter.\n"); 9 printf("please type in a letter: # to quit.\n" ); 10 while ((ch = getchar())!= # ) 11 { 12 if ( \n == ch) 108/145 C 语言

124 switch 语句 II 13 continue; 14 if (islower(ch)) 15 { 16 switch (ch) 17 { 18 case a : 19 printf("alligator\n"); 20 break; 21 case b : 22 printf("buffalo\n"); 23 break; 24 case c : 25 printf("camel\n"); 26 break; 27 case d : 28 printf("dove\n"); 109/145 C 语言

125 switch 语句 III 29 break; 30 case e : 31 printf("eagle\n"); 32 break; 33 default: 34 break; 35 } 36 } 37 else 38 printf("i only recognize only lowercase letters.\n"); 39 while (getchar()!= \n ) 40 continue; 41 printf("please typer another letter or a #.\ n"); 42 } 110/145 C 语言

126 switch 语句 IV 43 printf("bye!\n"); 44 return 0; 45 } 111/145 C 语言

127 switch 语句 Give a letter, and I will give you an animal name beginning with that letter. Please type in a letter: # to quit. dog dove Please typer another letter or a #. a alligator Please typer another letter or a #. eff eagle Please typer another letter or a #. # Bye! 112/145 C 语言

128 switch 语句 // switch 语法 switch (integer expression) { case constant1: statements case constant2: statements... default: statements } 113/145 C 语言

129 switch 语句 1 判断表达式应该具有整数值, 包括 int,char 和 enum 类型 114/145 C 语言

130 switch 语句 1 // switch1.c: float is not allowed in switch 2 #include <stdio.h> 3 int main(void) 4 { 5 float x = 1.1; 6 switch (x){ 7 case 1.1: printf("choice is 1"); 8 break; 9 default: printf("choice other than 1, 2 and 3" ); 10 break; 11 } 12 return 0; 13 } 14 // Compiler Error: switch quantity not an integer 115/145 C 语言

131 switch 语句 2 break 使程序跳出 switch 结构, 执行 switch 之后的下一条语句 若没有 break 语句, 从相匹配的标签到 switch 末尾的每一条语句都会被执行 116/145 C 语言

132 switch 语句 1 // switch2.c: There is no break in all cases 2 #include <stdio.h> 3 int main() 4 { 5 int x = 2; 6 switch (x) { 7 case 1: printf("choice is 1\n"); 8 case 2: printf("choice is 2\n"); 9 case 3: printf("choice is 3\n"); 10 default: printf("choice other than 1, 2 and 3\n"); 11 } 12 return 0; 13 } 117/145 C 语言

133 switch 语句 Choice is 2 Choice is 3 Choice other than 1, 2 and 3 118/145 C 语言

134 switch 语句 1 // switch3.c: There is no break in some cases 2 #include <stdio.h> 3 int main() 4 { 5 int x = 2; 6 switch (x){ 7 case 1: printf("choice is 1\n"); 8 case 2: printf("choice is 2\n"); 9 case 3: printf("choice is 3\n"); 10 case 4: printf("choice is 4\n"); break; 11 default: printf("choice other than 1, 2, 3 and 4\n"); break; 12 } 13 printf("after Switch"); 14 return 0; 15 } 119/145 C 语言

135 switch 语句 Choice is 2 Choice is 3 Choice is 4 After Switch 120/145 C 语言

136 switch 语句 3 case 标签必须是整型常量或整型常量表达式, 不能用变量作为 case 标签 121/145 C 语言

137 switch 语句 1 // switch4.c: A program with variable expressions in labels 2 #include <stdio.h> 3 int main() 4 { 5 int x = 2; 6 int arr[] = {1, 2, 3}; 7 switch (x) { 8 case arr[0]: printf("choice 1\n"); 9 case arr[1]: printf("choice 2\n"); 10 case arr[2]: printf("choice 3\n"); 11 } 12 return 0; 13 } 14 // Compiler Error: case label does not reduce to an integer constant 122/145 C 语言

138 switch 语句 4 default 语句块可放在 switch 结构中的任意位置, 若判断表达式与标签均不匹配, 它会被执行 123/145 C 语言

139 switch 语句 1 // switch5.c: The default block is placed above other cases. 2 #include <stdio.h> 3 int main() 4 { 5 int x = 4; 6 switch (x) { 7 default: printf("choice other than 1 and 2"); break; 8 case 1: printf("choice is 1"); break; 9 case 2: printf("choice is 2"); break; 10 } 11 return 0; 12 } 124/145 C 语言

140 switch 语句 1 // switch5.c: The default block is placed above other cases. 2 #include <stdio.h> 3 int main() 4 { 5 int x = 4; 6 switch (x) { 7 default: printf("choice other than 1 and 2"); break; 8 case 1: printf("choice is 1"); break; 9 case 2: printf("choice is 2"); break; 10 } 11 return 0; 12 } Choice other than 1 and 2 124/145 C 语言

141 switch 语句 I 5 case 之前的语句不会被执行 一旦进入 switch 结构, 将直接转入标签匹配 125/145 C 语言

142 switch 语句 I 1 // Statements before all cases are never executed 2 #include <stdio.h> 3 int main() 4 { 5 int x = 1; 6 switch (x) { 7 x = x + 1; // This statement is not executed 8 case 1: printf("choice is 1"); 9 break; 10 case 2: printf("choice is 2"); 11 break; 12 default: printf("choice other than 1 and 2"); 13 break; 126/145 C 语言

143 switch 语句 II 14 } 15 return 0; 16 } Choice is 1 127/145 C 语言

144 switch 语句 I 6 两个 case 标签不能有相同值 128/145 C 语言

145 switch 语句 I 1 // switch7.c: Program where two case labels have same value 2 #include <stdio.h> 3 int main() 4 { 5 int x = 1; 6 switch (x) { 7 case 2: printf("choice is 1"); 8 break; 9 case 1+1: printf("choice is 2"); 10 break; 11 } 12 return 0; 13 } 14 // Compiler Error: duplicate case value 129/145 C 语言

146 switch 语句 例编制程序, 输入一段文字, 按 # 停止输入, 然后统计该段文字中字母 a, e, i, o, u 出现的次数 ( 不计大小写 ) 130/145 C 语言

147 switch 语句 I 1 // vowels.c: 2 #include <stdio.h> 3 int main(void) 4 { 5 char ch; 6 int na, ne, ni, no, nu; 7 na = ne = ni = no = nu = 0; 8 printf("enter some text: enter # to quit.\n"); 9 while ((ch = getchar())!= # ) { 10 switch (ch) { 11 case a : 12 case A : na++; 13 break; 14 case e : 15 case E : ne++; 131/145 C 语言

148 switch 语句 II 16 break; 17 case i : 18 case I : ni++; 19 break; 20 case o : 21 case O : no++; 22 break; 23 case u : 24 case U : nu++; 25 break; 26 default: 27 break; 28 } 29 } 30 printf("number of text: %4c %4c %4c %4c\n", A, E, I, U ); 132/145 C 语言

149 switch 语句 III 31 printf(" %4d %4d %4d %4d\n", na, ne, ni, nu); 32 return 0; 33 } 133/145 C 语言

150 switch 语句 Enter some text: enter # to quit. See you tommorrow!# Number of text: A E I U /145 C 语言

151 switch 语句 若输入字母为 i, 则 switch 语句定位到标签为 case i : 的位置 因没有 break 同该标签相关联, 故程序将前进到下一条语句, 即 ni++ 若输入字母为 I, 程序将直接定位到这条语句 本质上, 两个标签都指向相同的语句 135/145 C 语言

152 switch 语句 在该例中, 可通过 ctype.h 中的 toupper 函数在进行判断之前将所有的字母转换为大写字母以避免多重标签 136/145 C 语言

153 switch 语句 ch = toupper(ch); switch (ch) { case A : na++; break; case E : ne++; break; case I : ni++; break; case O : no++; break; case U : nu++; break; default: break; } 137/145 C 语言

154 switch 语句 若希望保留 ch 的值不变, 可以这么做 switch (toupper(ch)) { case A : na++; break; case E : ne++; break; case I : ni++; break; case O : no++; break; case U : nu++; break; default: break; } 138/145 C 语言

155 switch 语句 :switch 与 if else 若选择是基于求一个浮点型变量或表达式的值, 就不能使用 switch 若变量必须落入某个范围, 使用 if 语句会更方便 如 if (integer < 1000 && integer > 2) 若可以使用 switch, 程序会运行得稍快些, 并且代码会更紧凑 139/145 C 语言

156 8. goto 语句

157 goto 语句 // goto 语法 goto label;... label: printf("refined analysis.\n"); goto 语句包括两个部分 :goto 和一个标签 标签的命名方式与变量命名相同 必须包含由标签定位的其它语句 : 标签名后紧跟一个冒号, 然后是一条语句 141/145 C 语言

158 goto 语句 goto 语句非常容易被滥用, 建议谨慎使用, 或者根本不用 142/145 C 语言

159 goto 语句 if (size > 12) goto a; goto b; a: cost *= 1.05; flag = 2; b: bill = cost * flag; 等效于 if (size > 12) { cost *= 1.05; flag = 2; } bill = cost * flag; 143/145 C 语言

160 goto 语句 if (n > 14) goto a; m = 2; goto b; a: m = 3; b: k = 2 * m; 等效于 if (size > 12) m = 2; else n = 3; k = 2 * m; 144/145 C 语言

161 goto 语句 readin: scanf("%d", &score); if (score < 0) goto stage2; lots of statements; goto readin; stage2: morestuff; 等效于 scanf("%d", &score); while (score >= 0) { lots of statements; scanf("%d", &score); } more stuff; 145/145 C 语言

162 goto 语句 调到循环末尾并开始下一轮循环, 用 continue 代替 跳出循环, 用 break 代替 事实上,break 和 continue 是 goto 的特殊形式 使用它们的好处是其名称表明会完成什么动作 ; 并且不需要标签, 故不存在错放标签位置的潜在危险 146/145 C 语言

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

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

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

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

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

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

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++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

CC213

CC213 : (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] : ,

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++程序设计 - 字符串与格式化输入/输出

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

新版 明解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++入門編 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

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

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

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 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 语言 第八讲 字符输入输出与输入确认 张晓平 武汉大学数学与统计学院 2017 年 4 月 12 日

C 语言 第八讲 字符输入输出与输入确认 张晓平 武汉大学数学与统计学院 2017 年 4 月 12 日 C 语言 第八讲 字符输入输出与输入确认 张晓平 武汉大学数学与统计学院 2017 年 4 月 12 日 1. 一个统计字数的程序 2. getchar 与 putchar 函数 3. 缓冲区 (Buffer) 4. 终止键盘输入 5. 创建一个更友好的用户界面 6. 输入确认 2/84 C 语言 7. 菜单浏览 3/84 C 语言 1. 一个统计字数的程序 一个统计字数的程序 编制程序, 读取一段文字,

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

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

Microsoft PowerPoint - 01_Introduction.ppt

Microsoft PowerPoint - 01_Introduction.ppt Hello, World C 程序设计语言 第 1 章章观其大略 孙志岗 sun@hit.edu.cn http://sunner.cn prf("hello,, world\n"); 超级无敌考考你 : 如何把 hello 和 world 分别打印在两行? 2004-12-19 A Tutorial Introduction 2 hello.c 打印华氏温度与摄氏温度对照表 计算公式 : C=(5/9)(

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

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

新・解きながら学ぶ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

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

《计算概论》课程 第十九讲 C 程序设计语言应用

《计算概论》课程 第十九讲  C 程序设计语言应用 计算概论 A 程序设计部分 字符数组与字符串 李戈 北京大学信息科学技术学院软件研究所 lige@sei.pku.edu.cn 字符数组的定义 #include int main() char a[10] = 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ; for (int i = 0; i < 10; i++) cout

More information

<4D F736F F F696E74202D BDE1B9B9BBAFB3CCD0F2C9E8BCC D20D1ADBBB7>

<4D F736F F F696E74202D BDE1B9B9BBAFB3CCD0F2C9E8BCC D20D1ADBBB7> 能源与动力工程学院 结构化编程 结构化程序设计 循环 循环结构 确定性循环 非确定性循环 I=1 sum=sum+i I = I +1 陈 斌 I>100 Yes No 目录 求和 :1+2+3++100 第四节循环的应用 PROGRAM GAUSS INTEGER I, SUM 计数器 SUM = 0 DO I = 1, 100, 1 SUM = SUM + I print*, I, SUM DO

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 4.4.1 逻辑运算符及其优先次序 3 种逻辑运算符 : &&( 逻辑与 ) ( 逻辑或 )!( 逻辑非 ) && 和 是双目 ( 元 ) 运算符! 是一目 ( 元 ) 运算符 逻辑表达式 用逻辑运算符将关系表达式或其他逻辑量连接起来的式子 4.4.1 逻辑运算符及其优先次序 判断年龄在 13 至 17 岁之内? age>=13 && age

More information

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

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 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

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

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3 浙江大学 C 程序设计及实验 试题卷 2002-2003 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:30-10:30 注意 : 答题内容必须写在答题卷上, 写在本试题卷上无效 一. 单项选择题 ( 每题 1 分, 共 10 分 ) 1. 下列运算符中, 优先级最低的是 A.

More information

untitled

untitled 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8 1-1-1 C int main(void){ int x,y,z; int sum=0; double avg=0.0; scanf("%d",&x) ; scanf("%d",&y) ; scanf("%d",&z) ; sum=x+y+z ; avg=sum/3.0; printf("%f\n",avg); system("pause");

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

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 第 六 讲 指 针 与 字 符 串 1 内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 指 针 什 么 是 指 针 指 针 的 定 义 与 运 算 指 针 与 一 维 数 组 指 针 数 组 行 指 针 与 二 维 数 组 指 针 与 引 用 指 针 与 函 数 3 指 针 定 义 什 么 是 指 针 指 针 变 量, 简 称 指 针, 用 来 存 放

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

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

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

第一章 引言

第一章  引言 第四章 循环结构 上机问题 程序书写风格 缩入 : 例如, 统一缩入四个空格 复合语句中 {} 的对齐 适当的空行 变量名命名 变量名使用 2 上机问题 关系运算符 == 与赋值运算符 = n == 0 与 n = 0 的区别? 逻辑运算符 :&& 与 的区别? && : 两个条件均为真, 结果为真 : 有一个条件为真, 结果为真 for 语句 if-else 语句的逻辑错误 3 上机问题 scanf

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

穨control.PDF

穨control.PDF TCP congestion control yhmiu Outline Congestion control algorithms Purpose of RFC2581 Purpose of RFC2582 TCP SS-DR 1998 TCP Extensions RFC1072 1988 SACK RFC2018 1996 FACK 1996 Rate-Halving 1997 OldTahoe

More information

C/C++ - 结构体、共用体、枚举体

C/C++ - 结构体、共用体、枚举体 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 C C (struct) C 2 C C (struct) C 2 i // book.c: # include < stdio.h> # define MAX_ TITLE 41 # define MAX_ AUTHOR 31 struct book { char title [ MAX_ TITLE

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

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2 Chapter 02 變數與運算式 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.2 2.2.1 2.2.2 2.2.3 type 2.2.4 2.3 2.3.1 print 2.3.2 input 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 + 2.4.6 Python Python 2.1 2.1.1 a p p l e b e a r c 65438790

More information

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2 WWW PHP 2003 1 Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2 Comments PHP Shell Style: # C++ Style: // C Style: /* */ $value = $p * exp($r * $t); # $value

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

FY.DOC

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

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

untitled

untitled 串 串 例 : char ch= a ; char str[]= Hello ; 串 列 ch=getchar(); scanf( %c,&ch); 串 gets(str) scanf( %s,str); 8-1 數 ASCII 例 : char ch= A ; printf( %d,ch); // 65 A ascii =0x41 printf( %c,ch); // A 例 : char ch;

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

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 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语言程序设计》讲义PPT

林子雨《C语言程序设计》讲义PPT C 语言程序设计 厦门大学计算机科学系 2013/3/19 林子雨 ziyulin@xmu.edu.cn 2013/3/19 厦门大学非计算机专业本科生公共课 (2012-2013 第 2 学期 ) C 语言程序设计 第 4 章选择结构林子雨 厦门大学计算机科学系 E-mail: ziyulin@xmu.edu.cn 个人主页 :http://www.cs.xmu.edu.cn/linziyu 课程提要

More information

Computer Architecture

Computer Architecture ECE 3120 Computer Systems Assembly Programming Manjeera Jeedigunta http://blogs.cae.tntech.edu/msjeedigun21 Email: msjeedigun21@tntech.edu Tel: 931-372-6181, Prescott Hall 120 Prev: Basic computer concepts

More information

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

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

More information

Microsoft PowerPoint - C_Structure.ppt

Microsoft PowerPoint - C_Structure.ppt 結構與其他資料型態 Janet Huang 5-1 結構的宣告 struct 結構名稱 struct 結構名稱變數 1, 變數 2,, 變數 m; struct 結構名稱 變數 1, 變數 2,, 變數 m; student; student; 5-2 1 結構變數初值的設定 struct 結構名稱 struct 結構名稱變數 = 初值 1, 初值 2,, 初值 n student="janet","1350901",100,95

More information

Microsoft Word - Final Exam Review Packet.docx

Microsoft Word - Final Exam Review Packet.docx Do you know these words?... 3.1 3.5 Can you do the following?... Ask for and say the date. Use the adverbial of time correctly. Use Use to ask a tag question. Form a yes/no question with the verb / not

More information

1.ai

1.ai HDMI camera ARTRAY CO,. LTD Introduction Thank you for purchasing the ARTCAM HDMI camera series. This manual shows the direction how to use the viewer software. Please refer other instructions or contact

More information

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

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

More information

科学计算的语言-FORTRAN95

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

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 - 01.DOC

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

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc 第 3 章 流程控制语句的应用 语句是程序中最小的程序指令, 即程序完成一次完整正操的基本单位 在 C# 中, 可以使用多种类型的语句, 每一种类型的语句又可以通过多个关键字实现 通过这些语句可以控制程序代码的逻辑, 提高程序的灵活性, 从而实现比较复杂的程序逻辑 本章主要内容 : 选择语句的应用 迭代语句的应用 跳转语句的应用 3.1 选择语句的应用 选择语句也叫作分支语句, 选择语句根据某个条件是否成立来控制程序的执行流程

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

Lorem ipsum dolor sit amet, consectetuer adipiscing elit

Lorem ipsum dolor sit amet, consectetuer adipiscing elit English for Study in Australia 留 学 澳 洲 英 语 讲 座 Lesson 3: Make yourself at home 第 三 课 : 宾 至 如 归 L1 Male: 各 位 朋 友 好, 欢 迎 您 收 听 留 学 澳 洲 英 语 讲 座 节 目, 我 是 澳 大 利 亚 澳 洲 广 播 电 台 的 节 目 主 持 人 陈 昊 L1 Female: 各 位

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

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

ebook14-4

ebook14-4 4 TINY LL(1) First F o l l o w t o p - d o w n 3 3. 3 backtracking parser predictive parser recursive-descent parsing L L ( 1 ) LL(1) parsing L L ( 1 ) L L ( 1 ) 1 L 2 L 1 L L ( k ) k L L ( 1 ) F i r s

More information

Ps22Pdf

Ps22Pdf ( 98 ) C ( ) ( )158 1998 C : C C C,,, C,, : C ( ) : : (, 100084) : : : 7871092 1/ 16 :18 25 :415 : 2000 3 1 2000 3 1 : ISBN 7 302 01166 4/ T P432 : 00016000 : 22 00 ( 98 ) 20 90,,, ;,,, 1994, 1998, 160,

More information

碩命題橫式

碩命題橫式 一 解釋名詞 :(50%) 1. Two s complement of an integer in binary 2. Arithmetic right shift of a signed integer 3. Pipelining in instruction execution 4. Highest and lowest layers in the TCP/IP protocol suite

More information

第 3 章选择结构 q q q Python 中表示条件的方法 if 语句 选择结构程序设计方法

第 3 章选择结构 q q q Python 中表示条件的方法 if 语句 选择结构程序设计方法 第 3 章选择结构 q q q Python 中表示条件的方法 if 语句 选择结构程序设计方法 3.1 条件的描述 3.1.1 关系运算 Python 的关系运算符有 : =( 大于等于 ) ==( 等于 )!=( 不等于 ) 关系运算符用于两个量的比较判断 由关系运算符将两个表达式连接起来的式子就称为关系表达式, 它用来表示条件, 其一般格式为

More information

Microsoft PowerPoint - ds-1.ppt [兼容模式]

Microsoft PowerPoint - ds-1.ppt [兼容模式] http://jwc..edu.cn/jxgl/ HomePage/Default.asp 2 说 明 总 学 时 : 72( 学 时 )= 56( 课 时 )+ 16( 实 验 ) 行 课 时 间 : 第 1 ~14 周 周 学 时 : 平 均 每 周 4 学 时 上 机 安 排 待 定 考 试 时 间 : 课 程 束 第 8 11 12 章 的 内 容 为 自 学 内 容 ; 目 录 中 标 有

More information

Knowledge and its Place in Nature by Hilary Kornblith

Knowledge and its Place in Nature by Hilary Kornblith Deduction by Daniel Bonevac Chapter 7 Quantified Natural Deduction Quantified Natural Deduction As with truth trees, natural deduction in Q depends on the addition of some new rules to handle the quantifiers.

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. 结构化程序设计所规定的三种基本结构是 C A 主程序 子程序 函数 B 树形 网形 环形 C 顺序 选择 循环 D 输入 处理 输出 2. 下列关于 C 语言的叙述错误的是 A A 对大小写不敏感 B 不同类型的变量可以在一个表达式中 C main 函数可以写在程序文件的任何位置 D 同一个运算符号在不同的场合可以有不同的含义 3. 以下合法的实型常数是 C A.E4

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

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 pnzwzw@163.com 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

, 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

BC04 Module_antenna__ doc

BC04 Module_antenna__ doc http://www.infobluetooth.com TEL:+86-23-68798999 Fax: +86-23-68889515 Page 1 of 10 http://www.infobluetooth.com TEL:+86-23-68798999 Fax: +86-23-68889515 Page 2 of 10 http://www.infobluetooth.com TEL:+86-23-68798999

More information

编译原理与技术

编译原理与技术 编译原理与技术 中间代码生成 2015/11/7 编译原理与技术 讲义 1 中间代码生成 - 布尔表达式翻译 - 控制流语句翻译 2015/11/7 编译原理与技术 讲义 2 布尔表达式的翻译 布尔表达式文法 G 4 E E 1 or E 2 E 1 and E 2 not E 1 ( E 1 ) id 1 relop id 2 true false id 3 布尔运算符 or and 和 not(

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

<4D F736F F D205A572D2D A1AAA1AAD4ACE7F42D43D3EFD1D4CAB5D1B5BDCCB3CC2E646F6378>

<4D F736F F D205A572D2D A1AAA1AAD4ACE7F42D43D3EFD1D4CAB5D1B5BDCCB3CC2E646F6378> 第 1 部分 Visual Studio 6.0 开发环境介绍 本书以 Visual C++ 6.0 作为 C 源程序的实践开发环境, 本章将首先介绍 Visual C++ 6.0 环境的基本操作, 包括 Visual C++ 6.0 的安装和启动,C 源程序的编辑 运行与调试 1.1 安装与启动 Visual C++ 6.0 MSDN Visual C++ 6.0 1.1 Microsoft Visual

More information

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f 27 1 Vol.27 No.1 CEMENTED CARBIDE 2010 2 Feb.2010!"!!!!"!!!!"!" doi:10.3969/j.issn.1003-7292.2010.01.011 OPC 1 1 2 1 (1., 412008; 2., 518052), OPC, WinCC VB,,, OPC ; ;VB ;WinCC Application of OPC Technology

More information

致 谢 本 论 文 能 得 以 完 成, 首 先 要 感 谢 我 的 导 师 胡 曙 中 教 授 正 是 他 的 悉 心 指 导 和 关 怀 下, 我 才 能 够 最 终 选 定 了 研 究 方 向, 确 定 了 论 文 题 目, 并 逐 步 深 化 了 对 研 究 课 题 的 认 识, 从 而 一

致 谢 本 论 文 能 得 以 完 成, 首 先 要 感 谢 我 的 导 师 胡 曙 中 教 授 正 是 他 的 悉 心 指 导 和 关 怀 下, 我 才 能 够 最 终 选 定 了 研 究 方 向, 确 定 了 论 文 题 目, 并 逐 步 深 化 了 对 研 究 课 题 的 认 识, 从 而 一 中 美 国 际 新 闻 的 叙 事 学 比 较 分 析 以 英 伊 水 兵 事 件 为 例 A Comparative Analysis on Narration of Sino-US International News Case Study:UK-Iran Marine Issue 姓 名 : 李 英 专 业 : 新 闻 学 学 号 : 05390 指 导 老 师 : 胡 曙 中 教 授 上 海

More information

Microsoft Word - PHP7Ch01.docx

Microsoft Word - PHP7Ch01.docx PHP 01 1-6 PHP PHP HTML HTML PHP CSSJavaScript PHP PHP 1-6-1 PHP HTML PHP HTML 1. Notepad++ \ch01\hello.php 01: 02: 03: 04: 05: PHP 06:

More information

领导,我不想写CSS代码.key

领导,我不想写CSS代码.key 领导 我不想写 CSS 张鑫旭 25MIN 2018-03-31 YUEWEN USER EXPERIENCE DESIGN 01 1 YUEWEN USER EXPERIENCE DESIGN 砖家 02 CSS - 艺术家 YUEWEN USER EXPERIENCE DESIGN 03 CSS - 砖家 艺术家 YUEWEN USER EXPERIENCE DESIGN 04 领导, 我不想写

More information

TX-NR3030_BAS_Cs_ indd

TX-NR3030_BAS_Cs_ indd TX-NR3030 http://www.onkyo.com/manual/txnr3030/adv/cs.html Cs 1 2 3 Speaker Cable 2 HDMI OUT HDMI IN HDMI OUT HDMI OUT HDMI OUT HDMI OUT 1 DIGITAL OPTICAL OUT AUDIO OUT TV 3 1 5 4 6 1 2 3 3 2 2 4 3 2 5

More information

国防常识

国防常识 ...1...14...14...18...19...26...28...30...31 97...40...40...41...42 ()...43...43...44...44...45...46 I ...47...47...48...49...49...52...53...54...54...55...57...58...59...61...62...62...64...66...68...69...72

More information

untitled

untitled 1 Outline 流 ( ) 流 ( ) 流 ( ) 流 ( ) 流 ( ) 狀 流 ( ) 利 來 行流 if () 立 行 ; else 不 立 行 ; 例 sample2-a1 (1) 列 // 料 Console.Write(""); string name = Console.ReadLine(); Console.WriteLine(" " + name + "!!"); 例 sample2-a1

More information

* RRB *

* RRB * *9000000000RRB0010040* *9000000000RRB0020040* *9000000000RRB0030040* *9000000000RRB0040040* *9000000000RRC0010050* *9000000000RRC0020050* *9000000000RRC0030050* *9000000000RRC0040050* *9000000000RRC0050050*

More information

热设计网

热设计网 例 例 Agenda Popular Simulation software in PC industry * CFD software -- Flotherm * Advantage of Flotherm Flotherm apply to Cooler design * How to build up the model * Optimal parameter in cooler design

More information

untitled

untitled 1 1.1 1.2 1.3 1.4 1.5 ++ 1.6 ++ 2 BNF 3 4 5 6 7 8 1.2 9 1.2 IF ELSE 10 1.2 11 1.2 12 1.3 Ada, Modula-2 Simula Smalltalk-80 C++, Objected Pascal(Delphi), Java, C#, VB.NET C++: C OOPL Java: C++ OOPL C# C++

More information

White Paper 2014 届 毕 业 生 内 部 资 料 严 禁 抄 袭 非 经 允 许 不 得 翻 印 就 业 状 况 白 皮 书 就 业 创 业 指 导 中 心 2015 年 5 月 目 录 第 一 部 分 毕 业 生 基 本 情 况... 1 一 2014 届 毕 业 生 基 本 情 况... 1 1 性 别 比 例... 1 2 学 历 类 别... 2 二 初 次 签 约 就 业

More information

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn Xi III Zebra XI III 1 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn 230V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666

More information

2009 Japanese First Language Written examination

2009 Japanese First Language Written examination Victorian Certificate of Education 2009 SUPERVISOR TO ATTACH PROCESSING LABEL HERE STUDENT NUMBER Letter Figures Words JAPANESE FIRST LANGUAGE Written examination Monday 16 November 2009 Reading time:

More information