C 语言 第八讲 字符输入输出与输入确认 张晓平 武汉大学数学与统计学院 2017 年 4 月 12 日

Size: px
Start display at page:

Download "C 语言 第八讲 字符输入输出与输入确认 张晓平 武汉大学数学与统计学院 2017 年 4 月 12 日"

Transcription

1 C 语言 第八讲 字符输入输出与输入确认 张晓平 武汉大学数学与统计学院 2017 年 4 月 12 日

2 1. 一个统计字数的程序 2. getchar 与 putchar 函数 3. 缓冲区 (Buffer) 4. 终止键盘输入 5. 创建一个更友好的用户界面 6. 输入确认 2/84 C 语言

3 7. 菜单浏览 3/84 C 语言

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

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

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

7 一个统计字数的程序 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 7/84 C 语言

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

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

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

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

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

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

14 一个统计字数的程序 为了判断一个字符是否在某个单词中, 可在读入一个单词的首字符时把一个标志 ( 命名为 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 12/84 C 语言

15 一个统计字数的程序 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"); 13/84 C 语言

16 一个统计字数的程序 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; 14/84 C 语言

17 一个统计字数的程序 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 } 15/84 C 语言

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

19 2. getchar 与 putchar 函数

20 getchar 与 putchar 函数 1 // echo.c: 2 #include <stdio.h> 3 int main(void) 4 { 5 char ch; 6 while ((ch = getchar())!= # ) 7 putchar(ch); 8 return 0; 9 } 18/84 C 语言

21 getchar 与 putchar 函数 1 // echo.c: 2 #include <stdio.h> 3 int main(void) 4 { 5 char ch; 6 while ((ch = getchar())!= # ) 7 putchar(ch); 8 return 0; 9 } Hello world Hello world I am happy I am happy 18/84 C 语言

22 3. 缓冲区 (Buffer)

23 缓冲区 (Buffer) 非缓冲输入 立即回显 : 键入的字符对正在等待的程序立即变为可用 HHeelllloo wwoorrlldd[enter] II aamm hhaappppyy[enter] 缓冲输入 延迟回显 : 键入的字符被存储在缓冲区中, 按下回车键使字符块对程序变为可用 20/84 C 语言

24 缓冲区 (Buffer): 为什么需要缓冲区? 将若干个字符作为一个块传输比逐个发送耗时要少 若输入有误, 可以使用键盘来修正错误 当最终按下回车键时, 便可发送正确的输入 21/84 C 语言

25 4. 终止键盘输入

26 终止键盘输入 程序 echo.c 在输入 # 时停止, 但有一个问题,# 可能就是你想输入的字符 于是, 我们自然希望终止字符不出现在文本中 23/84 C 语言

27 终止键盘输入 :EOF C 让 getchar 在到达文件结尾时返回一个特殊值, 其名称为 EOF(End Of File, 文件结尾 ) scanf() 在检测到文件结尾时也返回 EOF EOF 在头文件 stdio.h 中定义 #define EOF (-1) 24/84 C 语言

28 终止键盘输入 :EOF 为什么是 -1? 一般情况下,getchar() 返回一个 之间的值 ( 标准字符集 ), 或一个 的值 ( 扩展字符集 ) 在两种情况下,-1 都不对应任何字符, 故它可以表示文件结尾 25/84 C 语言

29 终止键盘输入 : 如何使用 EOF? 1 // echo_eof.c 2 #include <stdio.h> 3 int main(void) 4 { 5 int ch; 6 while ((ch = getchar())!= EOF) 7 putchar(ch); 8 return 0; 9 } 26/84 C 语言

30 终止键盘输入 : 如何使用 EOF? Hello world[enter] Hello world[ctrl+d] 27/84 C 语言

31 终止键盘输入 : 如何使用 EOF? 要对键盘使用该程序, 需要一种键入 EOF 的方式 在大多数 Unix 系统上, 在一行的开始位置键入 Ctrl+D 会导致传送文件尾信号 其它系统中, 可能将一行的开始位置键入的 Ctrl+Z 识别为文件尾信号, 也可能把任意位置键入的 Ctrl+Z 识别为文件尾信号 28/84 C 语言

32 终止键盘输入 : 如何使用 EOF? // Linux or Mac OS Hello world[enter] Hello world [Ctrl+D] 29/84 C 语言

33 5. 创建一个更友好的用户界面

34 创建一个更友好的用户界面 编制一个猜字程序, 看是否为 之间的某个整数 程序会依次问你是否为 1 2 3, 你回答 y 表示 yes, 回答 n 表示 no, 直到回答正确为止 31/84 C 语言

35 创建一个更友好的用户界面 I 1 // guess.c -- an inefficient and faulty numberguesser 2 #include <stdio.h> 3 int main(void) 4 { 5 int guess = 1; 6 printf("pick an integer from 1 to 100. I will "); 7 printf("try to guess it.\nrespond with "); 8 printf("a y if my guess is right and with"); 9 printf("\nan n if it is wrong.\n"); 10 printf("uh...is your number %d?\n", guess); 11 while (getchar()!= y ) 12 printf("well, then, is it %d?\n", ++guess); 13 printf("i knew I could do it!\n"); 32/84 C 语言

36 创建一个更友好的用户界面 II 14 return 0; 15 } 33/84 C 语言

37 创建一个更友好的用户界面 Pick an integer from 1 to 100. I will try to guess it. Respond with a y if my guess is right and with an n if it is wrong. Uh...is your number 1? n Well, then, is it 2? Well, then, is it 3? n Well, then, is it 4? Well, then, is it 5? y I knew I could do it! 34/84 C 语言

38 创建一个更友好的用户界面 输入 n 时, 竟然做了两次猜测,Why? 35/84 C 语言

39 创建一个更友好的用户界面 输入 n 时, 竟然做了两次猜测,Why? 是换行符,, 换行符在作怪 35/84 C 语言

40 创建一个更友好的用户界面 输入 n 时, 竟然做了两次猜测,Why? 是换行符,, 换行符在作怪 读入字符 n, 因 n!= y, 故打印 Well, then, is it 2? 紧接着读入字符 \n, 因 \n!= y, 故打印 Well, then, is it 3? 35/84 C 语言

41 创建一个更友好的用户界面 : 解决方案 使用一个 while 循环来丢弃输入行的其它部分, 包括换行符 1 while (getchar()!= y ) 2 { 3 printf("well, then, is it %d?\n", ++guess); 4 while (getchar()!= \n ) 5 continue; // skip rest of input line 6 } 这种处理办法还能把诸如 no 和 no way 这样的输入同简单的 n 一样看待 36/84 C 语言

42 创建一个更友好的用户界面 Pick an integer from 1 to 100. I will try to guess it. Respond with a y if my guess is right and with an n if it is wrong. Uh...is your number 1? n Well, then, is it 2? no Well, then, is it 3? no sir Well, then, is it 4? forget it Well, then, is it 5? y I knew I could do it! 37/84 C 语言

43 创建一个更友好的用户界面 若不希望将 f 的含义看做与 n 相同, 可使用一个 if 语句来筛选掉其它响应 1 char ch; while ((ch = getchar())!= y ) 4 { 5 if (ch == n ) 6 printf("well, then, is it %d?\n", ++guess); 7 else 8 printf("sorry, I understand only y or n.\n") ; 9 while (getchar()!= \n ) 10 continue; // skip rest of input line 11 } 38/84 C 语言

44 创建一个更友好的用户界面 Pick an integer from 1 to 100. I will try to guess it. Respond with a y if my guess is right and with an n if it is wrong. Uh...is your number 1? n Well, then, is it 2? no Well, then, is it 3? no sir Well, then, is it 4? forget it Sorry, I understand only y or n. n Well, then, is it 5? y I knew I could do it! 39/84 C 语言

45 创建一个更友好的用户界面 当你编写交互式程序时, 应试着去预料用户未能遵循指示的可能方式, 然后让程序能合理地处理用户的疏忽 并告诉用户哪里出了错误, 给予他们另一次机会 40/84 C 语言

46 创建一个更友好的用户界面 : 混合输入数字和字符 若你的程序需要使用 getchar() 输入字符和使用 scanf() 输入数字 两个函数都很很好的独立完成其工作, 但不能很好的混合在一起 因为 getchar() 读取每个字符, 包括空格 制表符和换行符 scanf() 在读取数字时会跳过空格 制表符和换行符 41/84 C 语言

47 创建一个更友好的用户界面 : 混合输入数字和字符 编写程序, 读取一个字符和两个整数, 然后使用这两个整数指定行数和列数打印该字符 42/84 C 语言

48 创建一个更友好的用户界面 : 混合输入数字和字符 I 1 /* showchar1.c -- program with a BIG I/O problem */ 2 #include <stdio.h> 3 void display(char cr, int lines, int width); 4 int main(void) 5 { 6 int ch; /* character to be printed */ 7 int rows, cols; /* number of rows and columns */ 8 printf("enter a character and two integers:\n" ); 9 while ((ch = getchar())!= \n ) { 10 scanf("%d %d", &rows, &cols); 11 display(ch, rows, cols); 43/84 C 语言

49 创建一个更友好的用户界面 : 混合输入数字和字符 II 12 printf("enter another character and two integers;\n"); 13 printf("enter a newline to quit.\n"); 14 } 15 printf("bye.\n"); 16 return 0; 17 } void display(char cr, int lines, int width) 20 { 21 int row, col; 22 for (row = 1; row<= lines; row++) 23 { 24 for (col = 1; col <= width; col++) 25 putchar(cr); 26 putchar( \n ); 44/84 C 语言

50 创建一个更友好的用户界面 : 混合输入数字和字符 III 27 } 28 } 45/84 C 语言

51 创建一个更友好的用户界面 : 混合输入数字和字符 Enter a character and two integers: c 2 3[enter] ccc ccc Enter another character and two integers; Enter a newline to quit. Bye. 46/84 C 语言

52 创建一个更友好的用户界面 : 混合输入数字和字符 程序开始时表现很好 当你输入 c 2 3 时, 如期打印 2 行 3 列 c 字符 然后程序提示输入第二组数据, 但还没等你输入程序就退出了 Why? 47/84 C 语言

53 创建一个更友好的用户界面 : 混合输入数字和字符 程序开始时表现很好 当你输入 c 2 3 时, 如期打印 2 行 3 列 c 字符 然后程序提示输入第二组数据, 但还没等你输入程序就退出了 Why? 又是它在作怪! 47/84 C 语言

54 创建一个更友好的用户界面 : 混合输入数字和字符 程序开始时表现很好 当你输入 c 2 3 时, 如期打印 2 行 3 列 c 字符 然后程序提示输入第二组数据, 但还没等你输入程序就退出了 Why? 又是它在作怪! 谁? 47/84 C 语言

55 创建一个更友好的用户界面 : 混合输入数字和字符 程序开始时表现很好 当你输入 c 2 3 时, 如期打印 2 行 3 列 c 字符 然后程序提示输入第二组数据, 但还没等你输入程序就退出了 Why? 又是它在作怪! 谁? 换行符! 47/84 C 语言

56 创建一个更友好的用户界面 : 混合输入数字和字符 程序开始时表现很好 当你输入 c 2 3 时, 如期打印 2 行 3 列 c 字符 然后程序提示输入第二组数据, 但还没等你输入程序就退出了 Why? 又是它在作怪! 谁? 换行符! 输入第一组数据后按下了换行符,scanf 将它留在了输入队列 而 getchar() 并不跳过换行符, 故在下一次循环时, getchar() 读取了该字符, 并将其值赋给了 ch, 而 ch 为换行符正是终止循环的条件 47/84 C 语言

57 创建一个更友好的用户界面 : 解决方案 程序必须跳过一个输入周期中最后一个数字与下一行开始出键入的字符之间的所有换行符或空格 若除了 getchar() 判断之外还可以在 scanf() 阶段终止程序, 则会更好 48/84 C 语言

58 创建一个更友好的用户界面 : 混合输入数字和字符 I 1 /* showchar2.c -- prints characters in rows and columns */ 2 #include <stdio.h> 3 void display(char cr, int lines, int width); 4 int main(void) 5 { 6 int ch; /* character to be printed */ 7 int rows, cols; /* number of rows and columns */ 8 printf("enter a character and two integers:\n" ); 9 while ((ch = getchar())!= \n ) { 10 if (scanf("%d %d",&rows, &cols)!= 2) break; 11 display(ch, rows, cols); 12 while (getchar()!= \n ) 49/84 C 语言

59 创建一个更友好的用户界面 : 混合输入数字和字符 II 13 continue; 14 printf("enter another character and two integers;\n"); 15 printf("enter a newline to quit.\n"); 16 } 17 printf("bye.\n"); 18 return 0; 19 } void display(char cr, int lines, int width) 22 { 23 int row, col; 24 for (row = 1; row<= lines; row++) 25 { 26 for (col = 1; col <= width; col++) 27 putchar(cr); 50/84 C 语言

60 创建一个更友好的用户界面 : 混合输入数字和字符 III 28 putchar( \n ); 29 } 30 } 51/84 C 语言

61 创建一个更友好的用户界面 : 混合输入数字和字符 Enter a character and two integers: c 1 3[enter] ccc Enter another character and two integers; Enter a newline to quit.! 3 6[enter]!!!!!!!!!!!!!!!!!! Enter another character and two integers; Enter a newline to quit. Bye. 52/84 C 语言

62 6. 输入确认

63 输入确认 在实际情况中, 用户并不总是遵循指令, 在程序所希望的输入与其实际输入之间可能存在不匹配, 这可能会导致程序运行失败 作为程序员, 你应该预见所有可能的输入错误, 修正程序以使其能检测到这些错误并作出处理 54/84 C 语言

64 输入确认 1 如有一个处理非负数的循环, 用户可能会输入一个负数, 你可以用一个关系表达式来检测这类错误 : int n; scanf("%d", &n); // get first value while (n >= 0) // detect out-of-range value { // process n scanf("%d", &n); // get next value } 55/84 C 语言

65 输入确认 2 当然用户还可能输入类型错误的值, 如字符 q 检测这类错误的方式是检测 scanf 的返回值 该函数返回成功读入的项目个数, 因此仅当用户输入一个整数时, 下列表达式为真 : scanf("%d", &n) == 1 56/84 C 语言

66 输入确认 考虑以上两种可能出现的输入错误, 我们可以对代码进行改进 : int n; while (scanf("%d", &n) == 1 && n >= 0) { // process n } while 循环的条件是 当输入是一个整数并且该整数为正 57/84 C 语言

67 输入确认 上面的例子中, 当输入类型有错时, 则终止输入 而更合适的处理方式是让程序对用户更加友好, 给用户尝试输入正确类型的机会 首先要剔除那些有问题的输入, 因 scanf 没有成功读取输入, 会将其留在输入队列中 然后使用 getchar() 来逐个字符地读取输入 58/84 C 语言

68 输入确认 编制程序, 计算特定范围内所有整数的平方和 限制这个特定范围的上届不应大于 1000, 下界不应小于 /84 C 语言

69 输入确认 I 1 /* checking.c -- validating input */ 2 #include <stdio.h> 3 #include <stdbool.h> 4 // validate that input is an integer 5 int get_int(void); 6 // validate that range limits are valid 7 bool bad_limits(int begin, int end, int low, int high); 8 // calculate the sum of the squares of the integer a through b 9 double sum_squares(int a, int b); 10 int main(void) 11 { 12 const int MIN = -1000; 13 const int MAX = +1000; 60/84 C 语言

70 输入确认 II 14 int start; 15 int stop; 16 double answer; 17 printf("this program computes the sum of the " 18 "squares of integers in a range.\n" 19 "The lower bound should not be less than " 20 "-1000 and\nthe upper bound should not " 21 "be more than \nEnter the limits " 22 "(enter 0 for both limits to quit):\n" 23 "lower limit: "); 24 start = get_int(); 25 printf("upper limit: "); 26 stop = get_int(); 61/84 C 语言

71 输入确认 III 27 while (start!=0 stop!= 0) { 28 if (bad_limits(start, stop, MIN, MAX)) 29 printf("please try again.\n"); 30 else { 31 answer = sum_squares(start, stop); 32 printf("the sum of the squares of the integers "); 33 printf("from %d to %d is %g\n", start, stop, answer); 34 } 35 printf("enter the limits (enter 0 for both " 36 "limits to quit):\n"); 37 printf("lower limit: "); 38 start = get_int(); 39 printf("upper limit: "); 40 stop = get_int(); 62/84 C 语言

72 输入确认 IV 41 } 42 printf("done.\n"); 43 return 0; 44 } 45 int get_int(void) 46 { 47 int input; 48 char ch; 49 while (scanf("%d", &input)!= 1) { 50 while ((ch = getchar())!= \n ) 51 putchar(ch); // dispose of bad input 52 printf(" is not an integer.\n"); 53 printf("please enter an integer value, "); 54 printf("such as 25, -178, or 3: "); 55 } 56 return input; 63/84 C 语言

73 输入确认 V 57 } 58 double sum_squares(int a, int b) { 59 double total = 0; 60 int i; 61 for (i = a; i <= b; i++) 62 total += i * i; 63 return total; 64 } 65 bool bad_limits(int begin, int end, int low, int high) 66 { 67 bool not_good = false; 68 if (begin > end) 69 { 70 printf("%d isn t smaller than %d.\n", 71 begin, end); 64/84 C 语言

74 输入确认 VI 72 not_good = true; 73 } 74 if (begin < low end < low) { 75 printf("values must be %d or greater.\n", 76 low); 77 not_good = true; 78 } 79 if (begin > high end > high) { 80 printf("values must be %d or less.\n", 81 high); 82 not_good = true; 83 } 84 return not_good; 85 } 65/84 C 语言

75 输入确认 对于 get_int(), 该函数试图将一个 int 值读入变量 input 若失败, 则该函数进入外层 while 循环, 然后内层 while 循环逐个字符地读取那些有问题的输入字符 然后该函数提示用户重新尝试 外层循环继续运行, 直至用户成功地输入一个整数 66/84 C 语言

76 输入确认 对于 bad_limits(), 用户输入一个下界和上界来定义值域 需要的检查可能有 第一个值是否小于等于第二个值 ; 两个值是否在可接受的范围内 67/84 C 语言

77 输入确认 I This program computes the sum of the squares of integers in a range. The lower bound should not be less than and the upper bound should not be more than Enter the limits (enter 0 for both limits to quit): lower limit: 1q upper limit: q is not an integer. Please enter an integer value, such as 25, -178, or 3: 3 The sum of the squares of the integers from 1 to 3 is 14 Enter the limits (enter 0 for both limits to quit): 68/84 C 语言

78 输入确认 II lower limit: q q is not an integer. Please enter an integer value, such as 25, -178, or 3: 3 upper limit: 5 The sum of the squares of the integers from 3 to 5 is 50 Enter the limits (enter 0 for both limits to quit): lower limit: 4 upper limit: 3q 4 isn t smaller than 3. Please try again. Enter the limits (enter 0 for both limits to quit): lower limit: q is not an integer. 69/84 C 语言

79 输入确认 III Please enter an integer value, such as 25, -178, or 3: 0 upper limit: 0 Done. 70/84 C 语言

80 输入确认 : 模块化编程 使用独立的函数来实现不同的功能 程序越大, 模块化编程就越重要 main 函数管理流程, 为其它函数指派任务 ; get_int 函数获取输入 ; badlimits 函数检查值的有效性 ; sum_squares 函数进行实际的计算 71/84 C 语言

81 输入确认 :C 输入的工作方式 假如有输入 is 在你看来, 该输入是一串字符 一个整数 一个浮点值 而对 C 来说, 该输入时一个字节流 第 1 个字节是字母 i 的字符编码第 2 个字节是字母 s 的字符编码第 3 个字节是空格字符的字符编码第 4 个字节是数字 2 的字符编码... 72/84 C 语言

82 输入确认 :C 输入的工作方式 当 getchar() 遇到这一行, 以下代码将读取并丢弃整行, 包括数字, 因为这些数字其实被看做是字符 : while((ch = getchar())!= \n ) putchar(ch); 73/84 C 语言

83 输入确认 :C 输入的工作方式 假如有输入 42 在使用 scanf() 函数时, 不同的占位符会导致不同的效果 74/84 C 语言

84 输入确认 :C 输入的工作方式 使用 %c, 将只读取字符 4 并将其存储在一个 char 型变量中 ; 使用 %s, 会读取两个字符, 即字符 4 和 2, 并将它们存储在一个字符串中 使用 %d, 同样读取两个字符, 但随后会计算与它们相应的整数值 = 42, 然后将该整数保存在一个 int 变量中 ; 使用 %f, 同样读取两个字符, 计算对应的数值 42, 然后以浮点表示法表示该值, 并将结果保存在一个 float 型变量中 75/84 C 语言

85 7. 菜单浏览

86 菜单浏览 菜单作为用户界面的一部分, 会使程序对用户更友好, 但也给程序员提出了一些新问题 Enter the letter of your choice: a. advice b. bell c. count q. quit 编程目标 : 让程序在用户遵循指令时顺利进行 让程序在用户没有遵循指令时也能顺利进行 77/84 C 语言

87 菜单浏览 编写程序, 确保有如下输出 : 78/84 C 语言

88 菜单浏览 Enter the letter of your choice: a. advice b. bell c. count q. quit a[enter] Buy low, sell high. Enter the letter of your choice: a. advice b. bell c. count q. quit b[enter] Enter the letter of your choice: a. advice b. bell c. count q. quit c[enter] Count how far? Enter an integer: two[enter] two is not an integer. 79/84 C 语言

89 菜单浏览 Please enter an integer value, such as 25, -178, or 3: 5[enter] Enter the letter of your choice: a. advice b. bell c. count q. quit q Bye. 80/84 C 语言

90 菜单浏览 I 1 /* menu.c -- menu techniques */ 2 #include <stdio.h> 3 char get_choice(void); 4 char get_first(void); 5 int get_int(void); 6 void count(void); 7 int main(void) 8 { 9 int choice; 10 while ( (choice = get_choice())!= q ) { 11 switch (choice) { 12 case a : printf("buy low, sell high.\n"); 13 break; 14 case b : putchar( \a ); 15 break; 81/84 C 语言

91 菜单浏览 II 16 case c : count(); 17 break; 18 default : printf("program error!\n"); 19 break; 20 } 21 } 22 printf("bye.\n"); 23 return 0; 24 } void count(void) 27 { 28 int n, i; 29 printf("count how far? Enter an integer:\n"); 30 n = get_int(); 31 for (i = 1; i <= n; i++) 82/84 C 语言

92 菜单浏览 III 32 printf("%d\n", i); 33 while ( getchar()!= \n ) 34 continue; 35 } char get_choice(void) 38 { 39 int ch; 40 printf("enter the letter of your choice:\n"); 41 printf("a. advice b. bell\n"); 42 printf("c. count q. quit\n"); 43 ch = get_first(); 44 while( (ch< a ch> c ) && ch!= q ) 45 { 46 printf("please respond with a, b, c, or q.\n "); 83/84 C 语言

93 菜单浏览 IV 47 ch = get_first(); 48 } 49 return ch; 50 } char get_first(void) 53 { 54 int ch; 55 ch = getchar(); 56 while (getchar()!= \n ) 57 continue; 58 return ch; 59 } int get_int(void) 62 { 84/84 C 语言

94 菜单浏览 V 63 int input; 64 char ch; 65 while (scanf("%d", &input)!= 1) { 66 while ((ch = getchar())!= \n ) 67 putchar(ch); // dispose of bad input 68 printf(" is not an integer.\n"); 69 printf("enter an integer value,\n"); 70 printf("such as 25, -178, or 3: "); 71 } 72 return input; 73 } 85/84 C 语言

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++ 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 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 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/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 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++语言 - 运算符、表达式和语句

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++ - 文件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 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++语言 - 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

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

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

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言語入門編

新版 明解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

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 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 语言 第七讲 分支 张晓平 武汉大学数学与统计学院 2017 年 4 月 5 日

C 语言 第七讲 分支 张晓平 武汉大学数学与统计学院 2017 年 4 月 5 日 C 语言 第七讲 分支 张晓平 武汉大学数学与统计学院 2017 年 4 月 5 日 1. if 语句 2. if else 语句 3. 获取逻辑性 4. 一个统计字数的程序 5. 条件运算符 6. continue 和 break 语句 2/145 C 语言 7. switch 语句 8. goto 语句 3/145 C 语言 1. if 语句 if 语句 I 1 // colddays.c: 2

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

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

( 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

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

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 程序设计语言应用 计算概论 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

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

プログラムの設計と実現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

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

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

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

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

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

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

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

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

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

第二章 臺灣客家族群民間信仰之發展

第二章 臺灣客家族群民間信仰之發展 自 進 入 臺 灣 大 學 迄 今, 不 覺 已 過 五 個 年 頭, 趕 在 學 期 的 最 後 幾 天 終 於 將 碩 士 論 文 完 成, 並 順 利 通 過 碩 士 論 文 口 試 常 想 自 己 是 否 天 資 愚 魯? 還 是 時 過 然 後 學, 則 勤 苦 而 難 成? 或 兩 者 皆 是? 我 永 遠 不 會 忘 記, 當 接 到 臺 大 國 家 發 展 研 究 所 的 錄 取 通

More information

FY.DOC

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

More information

南華大學數位論文

南華大學數位論文 1 Key word I II III IV V VI 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

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

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

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

马太亨利完整圣经注释—雅歌

马太亨利完整圣经注释—雅歌 第 1 页 目 录 雅 歌 简 介... 2 雅 歌 第 一 章... 2 雅 歌 第 二 章... 10 雅 歌 第 三 章... 16 雅 歌 第 四 章... 20 雅 歌 第 五 章... 25 雅 歌 第 六 章... 32 雅 歌 第 七 章... 36 雅 歌 第 八 章... 39 第 2 页 雅 歌 简 介 我 们 坚 信 圣 经 都 是 神 所 默 示 的 ( 提 摩 太 后 书

More information

二零零六年一月二十三日會議

二零零六年一月二十三日會議 附 件 B 有 关 政 策 局 推 行 或 正 在 策 划 的 纾 缓 及 预 防 贫 穷 措 施 下 文 载 述 有 关 政 策 局 / 部 门 为 加 强 纾 缓 及 预 防 贫 穷 的 工 作, 以 及 为 配 合 委 员 会 工 作, 在 过 去 十 一 个 月 公 布 及 正 在 策 划 的 新 政 策 和 措 施 生 福 利 及 食 物 局 (i) 综 合 儿 童 发 展 服 务 2.

More information

厨房小知识(四)

厨房小知识(四) I...1...2...3...4...4...5...6...6...7...9...10... 11...12...12...13...14...15...16...17...18...18...19...22...22 II...23...24...25...26...27...27...28...29...29...30...31...31?...32...32...33?...33...34...34...35...36...36...37...37...38...38...40

More information

妇女更年期保健.doc

妇女更年期保健.doc ...1...2...3...5...6...7 40...8... 11...13...14...16...17...19...20...21...26...29...30...32 I ...34...35...37...41...46...50...51...52...53...54...55...58...64...65 X...67...68...70...70...74...76...78...79

More information

小儿传染病防治(上)

小儿传染病防治(上) ...1...2...3...5...7...7...9... 11...13...14...15...16...32...34...34...36...37...39 I ...39...40...41...42...43...48...50...54...56...57...59...59...60...61...63...65...66...66...68...68...70...70 II

More information

<4D6963726F736F667420576F7264202D2031303430333234B875B9B5A448ADFBBADEB27AA740B77EA4E2A5555FA95EAED6A641ADD75F2E646F63>

<4D6963726F736F667420576F7264202D2031303430333234B875B9B5A448ADFBBADEB27AA740B77EA4E2A5555FA95EAED6A641ADD75F2E646F63> 聘 僱 人 員 管 理 作 業 參 考 手 冊 行 政 院 人 事 行 政 總 處 編 印 中 華 民 國 104 年 3 月 序 人 事 是 政 通 人 和 的 關 鍵 是 百 事 俱 興 的 基 礎, 也 是 追 求 卓 越 的 張 本 唯 有 人 事 健 全, 業 務 才 能 順 利 推 動, 政 府 施 政 自 然 績 效 斐 然 本 總 處 做 為 行 政 院 人 事 政 策 幕 僚 機

More information

女性青春期保健(下).doc

女性青春期保健(下).doc ...1...4...10... 11...13...14...15...17...18...19...20...21...22...23...24...26...27...30...31 I ...32...33...36...37...38...40...41...43...44...45...46...47...50...51...51...53...54...55...56...58...59

More information

避孕知识(下).doc

避孕知识(下).doc ...1...3...6...13...13...14...15...16...17...17...18...19...19...20...20...23...24...24...25 I ...25...26...26...27...28...28...29...30...30...31...32...34...35 11...36...37...38...40...42...43...44...44...46

More information

孕妇饮食调养(下).doc

孕妇饮食调养(下).doc ...1...2...5...9 7...9...14...15...16...18...22...23...24...25...27...29...31...32...34 I ...35...36...37...39...40...40...42...44...46...48...51...52...53...53...54...55...56...56...58...61...64 II ...65...66...67...68...69...70...71...72...73...74...75...76...77...80...83...85...87...88

More information

禽畜饲料配制技术(一).doc

禽畜饲料配制技术(一).doc ( ) ...1...1...4...5...6...7...8...9...10... 11...13...14...17...18...21...23...24...26 I ...28 70...30...33...35...36...37...39...40...41...49...50...52...53...54...56...58...59...60...67...68...70...71

More information

中老年保健必读(十一).doc

中老年保健必读(十一).doc ...1...2...4...6...8...9...10...12...14...15...17...18...20...22...23...25...27...29 I ...30...32...35...38...40...42...43...45...46...48...52...55...56...59...62...63...66...67...69...71...74 II ...76...78...79...81...84...86...87...88...89...90...91...93...96...99...

More information

i

i i ii iii iv v vi 1 2 3 4 5 (b) (a) (b) (c) = 100% (a) 6 7 (b) (a) (b) (c) = 100% (a) 2 456 329 13% 12 120 7.1 0.06% 8 9 10 11 12 13 14 15 16 17 18 19 20 (a) (b) (c) 21 22 23 24 25 26 27 28 29 30 31 =

More information

怎样使孩子更加聪明健康(七).doc

怎样使孩子更加聪明健康(七).doc ...1...2...2...4...5 7 8...6...7...9 1 3... 11...12...14...15...16...17...18...19...20...21...22 I II...23...24...26 1 3...27...29...31...31...33...33...35...35...37...39...41...43...44...45 3 4...47...48...49...51...52

More information

i

i i ii iii iv v vi 1 g j 2 3 4 ==== ==== ==== 5 ==== ======= 6 ==== ======= 7 ==== ==== ==== 8 [(d) = (a) (b)] [(e) = (c) (b)] 9 ===== ===== ===== ===== ===== ===== 10 11 12 13 14 15 16 17 ===== [ ] 18 19

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

2_ Bridegroom fast 1 - v1

2_ Bridegroom fast 1 - v1 學 習 主 旨 : 認 識 耶 穌 新 郎 神 的 愛, 和 教 會 新 婦 的 位 份 藉 著 禁 食 來 思 念 耶 穌 更 加 經 歷 耶 穌 的 同 在, 及 對 耶 穌 榮 美 的 開 啟, 直 到 主 再 來 中 經 : 太 9:15 耶 穌 對 他 們 說 : 新 郎 和 陪 伴 之 人 同 在 的 時 候, 陪 伴 之 人 豈 能 哀 慟 呢? 但 日 子 將 到, 新 郎 要 離

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

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

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

More information

一 敬 拜 诗 歌 二 灵 修 读 经 - 传 道 书 第 五 章 在 神 前 存 敬 畏 的 心 Ecc 5:1 你 到 神 的 殿 要 谨 慎 脚 步 ; 因 为 近 前 听, 胜 过 愚 昧 人 献 祭 ( 或 作 : 胜 过 献 愚 昧 人 的 祭 ), 他 们 本 不 知 道 所 做 的

一 敬 拜 诗 歌 二 灵 修 读 经 - 传 道 书 第 五 章 在 神 前 存 敬 畏 的 心 Ecc 5:1 你 到 神 的 殿 要 谨 慎 脚 步 ; 因 为 近 前 听, 胜 过 愚 昧 人 献 祭 ( 或 作 : 胜 过 献 愚 昧 人 的 祭 ), 他 们 本 不 知 道 所 做 的 第 一 九 三 天 2015-08-19 一 敬 拜 诗 歌 给 我 清 洁 的 心 二 灵 修 读 经 传 道 书 第 5 章 三 旧 约 行 程 约 伯 记 第 38-40 章 四 新 约 行 程 歌 罗 西 书 第 1 章 五 每 日 灵 粮 第 1 页 一 敬 拜 诗 歌 二 灵 修 读 经 - 传 道 书 第 五 章 在 神 前 存 敬 畏 的 心 Ecc 5:1 你 到 神 的 殿 要

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

untitled

untitled CHAPTER 02 2 CHAPTER 2-1 2-4 2-2 2-5 2-3 2-6 2-1 2-1-1 2-2 02 int A[3] = {10, 20, 30; A[0] 10 A[1] 20 A[2] 30 int *pa[3], A[3]; C 3 pa pa[0]pa[1]pa[2] 3 A A[0]A[1]A[2] 3 A A[0] A + i A[i] A + i &A[i]*(A

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

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 範 例 試 題 (C++) 試 題 編 號 :11900-920201-4 審 定 日 期 : 94 年 7 月 1 日 修 訂 日 期 : 96 年 2 月 1 日 97 年 1 月 30 日 ( 第 二 部 份 ) 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 應 檢 參 考 資 料 壹 試

More information

四川省普通高等学校

四川省普通高等学校 四 川 省 普 通 高 等 学 校 计 算 机 应 用 知 识 和 能 力 等 级 考 试 考 试 大 纲 (2013 年 试 行 版 ) 四 川 省 教 育 厅 计 算 机 等 级 考 试 中 心 2013 年 1 月 目 录 一 级 考 试 大 纲 1 二 级 考 试 大 纲 6 程 序 设 计 公 共 基 础 知 识 6 BASIC 语 言 程 序 设 计 (Visual Basic) 9

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

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

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++ 程式設計

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

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING 前言 - Andrew Payne 目录 1 2 Firefly Basics 3 COMPONENT TOOLBOX 目录 4 RESOURCES 致谢

More information

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

More information

期中考试试题讲解

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

More information

(Chi)_.indb

(Chi)_.indb 1,000,000 4,000,000 1,000,000 10,000,000 30,000,000 V-1 1,000,000 2,000,000 20,000,00010,000,0005,000,000 3,000,000 30 20% 35% 20%30% V-2 1) 2)3) 171 10,000,00050% 35% 171 V-3 30 V-4 50,000100,000 1) 2)

More information

14A 0.1%5% 14A 14A.52 1 2 3 30 2

14A 0.1%5% 14A 14A.52 1 2 3 30 2 2389 30 1 14A 0.1%5% 14A 14A.52 1 2 3 30 2 (a) (b) (c) (d) (e) 3 (i) (ii) (iii) (iv) (v) (vi) (vii) 4 (1) (2) (3) (4) (5) 400,000 (a) 400,000300,000 100,000 5 (b) 30% (i)(ii) 200,000 400,000 400,000 30,000,000

More information

穨_2_.PDF

穨_2_.PDF 6 7.... 9.. 11.. 12... 14.. 15.... 3 .. 17 18.. 20... 25... 27... 29 30.. 4 31 32 34-35 36-38 39 40 5 6 : 1. 2. 1. 55 (2) 2. : 2.1 2.2 2.3 3. 4. ( ) 5. 6. ( ) 7. ( ) 8. ( ) 9. ( ) 10. 7 ( ) 1. 2. 3. 4.

More information

女性减肥健身(四).doc

女性减肥健身(四).doc ...1...2...3...4...6...7...8...10... 11...14...16...17...23...25...26...28...30...30 I ...31 10...33...36...39...40...42...44...47...49...53...53 TOP10...55...58...61...64...65...66...68...69...72...73

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

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

Microsoft PowerPoint - 異常事件管理20101106 [相容模式]

Microsoft PowerPoint - 異常事件管理20101106 [相容模式] 異 常 事 件 管 理 紀 淑 靜 2010.11.06 1 異 常 事 件 管 理 一 前 言 二 病 人 ( 個 案 ) 為 中 心 的 思 維 三 機 構 中 常 見 的 異 常 事 件 四 異 常 災 害 形 成 的 原 因 五 異 常 事 件 預 防 的 意 義 六 跌 倒 高 危 險 群 的 評 估 七 異 物 梗 塞 八 異 常 事 件 處 理 流 程 九 案 例 分 析 十 結 語

More information

The return of scanf The number of fields successfully converted and assigned int a =1, b =2, c =3; int n = scanf("%d %d %d", &a, &b, &c); printf("%d\n

The return of scanf The number of fields successfully converted and assigned int a =1, b =2, c =3; int n = scanf(%d %d %d, &a, &b, &c); printf(%d\n Introduction to Computer and Program Design Lesson 2 Functions, scanf and EOF James C.C. Cheng Department of Computer Science National Chiao Tung University The return of scanf The number of fields successfully

More information

項 訴 求 在 考 慮 到 整 體 的 財 政 承 擔 以 及 資 源 分 配 的 公 平 性 下, 政 府 採 取 了 較 簡 單 直 接 的 一 次 性 減 稅 和 增 加 免 稅 額 方 式, 以 回 應 中 產 家 庭 的 不 同 訴 求 ( 三 ) 取 消 外 傭 徵 費 6. 行 政 長

項 訴 求 在 考 慮 到 整 體 的 財 政 承 擔 以 及 資 源 分 配 的 公 平 性 下, 政 府 採 取 了 較 簡 單 直 接 的 一 次 性 減 稅 和 增 加 免 稅 額 方 式, 以 回 應 中 產 家 庭 的 不 同 訴 求 ( 三 ) 取 消 外 傭 徵 費 6. 行 政 長 2013 年 1 月 23 日 的 立 法 會 會 議 葛 珮 帆 議 員 就 幫 助 中 產 動 議 的 議 案 ( 經 單 仲 偕 議 員 及 莫 乃 光 議 員 修 正 ) 進 度 報 告 在 2013 年 1 月 23 日 的 立 法 會 會 議 上, 由 葛 珮 帆 議 員 就 幫 助 中 產 動 議 的 議 案, 經 單 仲 偕 議 員 及 莫 乃 光 議 員 修 正 後 獲 得 通 過

More information

(f) (g) (h) (ii) (iii) (a) (b) (c) (d) 208

(f) (g) (h) (ii) (iii) (a) (b) (c) (d) 208 (a) (b) (c) (d) (e) 207 (f) (g) (h) (ii) (iii) (a) (b) (c) (d) 208 17.29 17.29 13.16A(1) 13.18 (a) (b) 13.16A (b) 12 (a) 209 13.19 (a) 13.16A 12 13.18(1) 13.18(4) 155 17.43(1) (4) (b) 13.19 17.43 17.29

More information

Microsoft Word - 08 单元一儿童文学理论

Microsoft Word - 08 单元一儿童文学理论 单 元 ( 一 ) 儿 童 文 学 理 论 内 容 提 要 : 本 单 元 共 分 成 三 个 小 课 目, 即 儿 童 文 学 的 基 本 理 论 儿 童 文 学 创 作 和 儿 童 文 学 的 鉴 赏 与 阅 读 指 导 儿 童 文 学 的 基 本 理 论 内 容 包 括 儿 童 文 学 的 基 本 含 义 儿 童 文 学 读 者 儿 童 文 学 与 儿 童 年 龄 特 征 和 儿 童 文 学

More information

untitled

untitled 1993 79 2010 9 80 180,000 (a) (b) 81 20031,230 2009 10,610 43 2003 2009 1,200 1,000 924 1,061 800 717 600 530 440 400 333 200 123 0 2003 2004 2005 2006 2007 2008 2009 500 2003 15,238 2009 31,4532003 2009

More information

南華大學數位論文

南華大學數位論文 南 華 大 學 哲 學 與 生 命 教 育 學 系 碩 士 論 文 呂 氏 春 秋 音 樂 思 想 研 究 研 究 生 : 何 貞 宜 指 導 教 授 : 陳 章 錫 博 士 中 華 民 國 一 百 零 一 年 六 月 六 日 誌 謝 論 文 得 以 完 成, 最 重 要 的, 是 要 感 謝 我 的 指 導 教 授 陳 章 錫 博 士, 老 師 總 是 不 辭 辛 勞 仔 細 閱 讀 我 的 拙

More information

Microsoft Word - 3.3.1 - 一年級散文教案.doc

Microsoft Word - 3.3.1 - 一年級散文教案.doc 光 明 英 來 學 校 ( 中 國 文 學 之 旅 --- 散 文 小 說 教 學 ) 一 年 級 : 成 語 ( 主 題 : 勤 學 ) 節 數 : 六 教 節 ( 每 課 題 一 教 節 ) 課 題 : 守 株 待 兔 半 途 而 廢 愚 公 移 山 鐵 杵 磨 針 孟 母 三 遷 教 學 目 的 : 1. 透 過 活 動, 學 生 能 說 出 成 語 背 後 的 含 意 2. 學 生 能 指

More information

第32回独立行政法人評価委員会日本貿易保険部会 資料1-1 平成22年度財務諸表等

第32回独立行政法人評価委員会日本貿易保険部会 資料1-1 平成22年度財務諸表等 1 12,403 2,892 264,553 19,517 238,008 10,132 989 36 9,869 2,218 250 122 ( 126 108 1,563 278 159 260 478 35,563 1,073 74 190,283 104,352 140,658 20,349 16,733 21,607 (21,607) 58,689 303,699 339,262 339,262

More information

第三章

第三章 第 三 章 :2017 年 行 政 長 官 產 生 辦 法 - 可 考 慮 的 議 題 行 政 長 官 的 憲 制 及 法 律 地 位 3.01 基 本 法 第 四 十 三 條 規 定 : 香 港 特 別 行 政 區 行 政 長 官 是 香 港 特 別 行 政 區 的 首 長, 代 表 香 港 特 別 行 政 區 香 港 特 別 行 政 區 行 政 長 官 依 照 本 法 的 規 定 對 中 央 人

More information

nb.PDF

nb.PDF 3 4 5 7 8 9..10..15..16..19..52 -3,402,247-699,783-1,611,620 1,790,627 : - - -7,493 - -1,687 2,863 1,176 2,863 - -148,617 - - 12,131 51,325 - -12,131-2,165 14-2,157 8-3,393,968-794,198-1,620,094 1,781,367

More information

bnbqw.PDF

bnbqw.PDF 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ( ( 1 2 16 1608 100004 1 ( 2003 2002 6 30 12 31 7 2,768,544 3,140,926 8 29,054,561 40,313,774 9 11,815,996 10,566,353 11 10,007,641 9,052,657 12 4,344,697

More information

Microsoft Word - 發布版---規範_全文_.doc

Microsoft Word - 發布版---規範_全文_.doc 建 築 物 無 障 礙 設 施 設 計 規 範 內 政 部 97 年 4 年 10 日 台 內 營 字 第 0970802190 號 令 訂 定, 自 97 年 7 月 1 日 生 效 內 政 部 97 年 12 年 19 日 台 內 營 字 第 0970809360 號 令 修 正 內 政 部 101 年 11 年 16 日 台 內 營 字 第 1010810415 號 令 修 正 目 錄 第 一

More information

概 述 随 着 中 国 高 等 教 育 数 量 扩 张 目 标 的 逐 步 实 现, 提 高 教 育 质 量 的 重 要 性 日 益 凸 显 发 布 高 校 毕 业 生 就 业 质 量 年 度 报 告, 是 高 等 学 校 建 立 健 全 就 业 状 况 反 馈 机 制 引 导 高 校 优 化 招

概 述 随 着 中 国 高 等 教 育 数 量 扩 张 目 标 的 逐 步 实 现, 提 高 教 育 质 量 的 重 要 性 日 益 凸 显 发 布 高 校 毕 业 生 就 业 质 量 年 度 报 告, 是 高 等 学 校 建 立 健 全 就 业 状 况 反 馈 机 制 引 导 高 校 优 化 招 I 概 述 随 着 中 国 高 等 教 育 数 量 扩 张 目 标 的 逐 步 实 现, 提 高 教 育 质 量 的 重 要 性 日 益 凸 显 发 布 高 校 毕 业 生 就 业 质 量 年 度 报 告, 是 高 等 学 校 建 立 健 全 就 业 状 况 反 馈 机 制 引 导 高 校 优 化 招 生 和 专 业 结 构 改 进 人 才 培 养 模 式 及 时 回 应 社 会 关 切 的 一 项

More information

鱼类丰产养殖技术(二).doc

鱼类丰产养殖技术(二).doc ...1...1...4...15...18...19...24...26...31...35...39...48...57...60...62...66...68...72 I ...73...88...91...92... 100... 104... 144... 146... 146... 147... 148... 148... 148... 149... 149... 150... 151...

More information

疾病诊治实务(一)

疾病诊治实务(一) ...1...4...5...8...13...14...15...18...18...19...22...25...26...27...29...30...32...35 I ...38...42...43...45...48...51...53...56...59...60...60...61...63...65...67...69...72...74...77...80...82...84 II

More information

名人养生.doc

名人养生.doc I...1...3...4...6... 11...14...18...22...26...29...31...38...45...49...56...57...59...61...67 ...72...73...75...77...80...83...85...91...92...93...95...96...97... 103... 107... 109... 110... 112... 118...

More information

<4D6963726F736F667420576F7264202D2040B9C5B871A661B0CFABC8AE61C2A7AB55ACE3A8735FA7F5ABD8BFB3B9C5B871A661B0CFABC8AE61C2A7AB55ACE3A8732E646F63>

<4D6963726F736F667420576F7264202D2040B9C5B871A661B0CFABC8AE61C2A7AB55ACE3A8735FA7F5ABD8BFB3B9C5B871A661B0CFABC8AE61C2A7AB55ACE3A8732E646F63> 嘉 義 地 區 客 家 禮 俗 研 究 第 一 章 前 言 嘉 義 地 區 的 客 家 族 群 約 略 可 分 為 福 佬 客 詔 安 客 與 北 部 客 等 三 種 類 別, 其 分 佈 區 域 以 海 線 地 區 平 原 地 形 沿 山 地 區 為 主 有 相 當 多 的 北 部 客 家 人, 是 二 次 大 戰 末 期 和 戰 後 初 期 才 移 民 嘉 義, 是 什 麼 因 素 令 許 多

More information