c语言作业s(C language s).doc

上传人:rrsccc 文档编号:9274781 上传时间:2021-02-14 格式:DOC 页数:25 大小:52KB
返回 下载 相关 举报
c语言作业s(C language s).doc_第1页
第1页 / 共25页
c语言作业s(C language s).doc_第2页
第2页 / 共25页
c语言作业s(C language s).doc_第3页
第3页 / 共25页
c语言作业s(C language s).doc_第4页
第4页 / 共25页
c语言作业s(C language s).doc_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《c语言作业s(C language s).doc》由会员分享,可在线阅读,更多相关《c语言作业s(C language s).doc(25页珍藏版)》请在三一文库上搜索。

1、c语言作业s(C language s)The chapter exercisesThe first chapter1. a C source program must have a main function.The 2. function is the basic unit of C program structure.3. a C program always start from the main function implementation.4. in the C language, a general function consists of two parts, which i

2、s a function of the header and body function.The 5.C statement is in the end.6. notes on any part of the C program with the / * /.7. the following 4 options, all is the C language keyword option is B.A) auto b) switch C) else d) ifChar void extern structInclude continue scanf type8. of the 4 groups

3、of options, are not the C keyword is a.A) define b) Getc C) include d) whileScanf char if goType printf case powThe second chapterThe algorithm represented by N-S discriminant prime graph.The third chapterThe following is the constant group C legal C language major.A) 1101ab 0f ABC 3.e5 B -0 9E)C 1E

4、5 0xa d $).5e-5 0198 E3.02. if there is a definition: char c= 010; the variable number of characters contained in the C 1.3. the length of the string abn012 is 9.In the 4.C language, the constant 18 three specific representation of 18022 0x12.The 5.C language identifier only by letters, numbers, und

5、erline 3 characters, the first character of C.Must be a letterB) must be underlinedC) must be a letter or an underscoreD) is any letter, number or underscore in6. of the 4 groups of options, are C language legitimate user identifier option is B.A TIMP abc$suml) B day day_1 _day)C day-1 3AB sum d) m.

6、d.j class 123)7. in C, int, char between the number of bytes of double and three types of data in the memory occupied by charintdouble.8. if a definition: char a=123, b=456 int sum; sum=a+b; implementation; after the 67 is the value of sum.9. types of variables known as follows:Int i=8, K, a, b;Unsi

7、gned long w=5;Double x=1.42, y=5.2;The following is consistent with expression of C grammar is a.(a) a + = a = (b = 4) * (a = 3) (b) (a = a * 3 = 2 (c) x% (- 3.0) (d) (i), y = float10.以下符合c语言语法的赋值表达式是 b.d = 9 + e + f = d + 9 (b) (d = e = f = d + 9(c), (d = 9 + e, e + +, d + 9 (d) (d = 9 + e + + = d

8、+ 911.a是int型变量, 则下面表达式的值为 2 6.(a = 4 * 5, * 2 (a), (a + 612.如有定义int (a = 7; float x = 2.5, y = 4.7; 则表达式x + a% 3 * (int) (x + y)%, 2 / 4的值是 a.(a) 2.500000 (b) c) d) 0.000000 3.500000 2.75000013.设变量a为整型, f为实型, i为双精度, 则表达式10 + (a) + i * f值的数据类型为双精度型.14.已知字a的asc码为十进制数97, 且设ch 为字符型变量, 则表达式ch = a + 8 - 3

9、 的值为 f (或102).15.假设变量a和b均为整型, 则以下语句的功能是 a、b变量的值互换.a + = b; b = a - b; a = b;16.若定义int (i = 1, c; 表达式 c = (i, i + +) 的值是 1, c = (i + +, (i) 的值是 2.第四章1.设x为int型, y为double型变量, 则以下合法的输入语句为 c.(a) scanf (% d% 5.1f, & x & y); (b) scanf (% 5d% f , & x & y);(c) scanf (% d% lf, & x & y); (d) scanf (% ld,% f ,

10、& x & y);2.如有以下定义和语句, 为使变量c1得到字符a, 变量c2得到字符b, 正确的格式输入形式是 a, b,.char c1, c2;scanf (% 4% 4c, & c1 & c2):3.已有定义int x, float y; 且执行scanf (% 3d% f , & x & y); 语句, 如从第一列开始输入数据12345 678 , 则y的值为 45.第五章1.运算符! = & &, =% 的优先级顺序是% ! = & & =,.2.在运算符! = + & &, = 中, 右结合的有 =.3.如有: int a = 1, b = 2, c = 3, d = 4, m

11、= 5, n = 6; 执行 (m = (a b) & & (n = c d) 后n的值为 6.4.a = 6, b = 4, c = 2, 则表达式! (a - b) + (c - 1 & & b + c / 2的值是 1.5.将条件 x不能被3整除, 也不能被5整除, 但能被7整除 写成c语言的逻辑表达式 x% 3! = 0 & & x% 5. = 0 & & x% 7 = = 0.6.设y为int型变量且y 0, 请写出描述 y是奇数 的逻辑表达式 y% 2! = 0.7.And s= (ab)? A:b; if statements equivalent to if (ab) s=a;

12、 else s=b;.8. if the statement int i=5, j=4, k=6; float f; execute f= statement (ij&ik)? I: (jb? : , b); after the output is 5y&x =y b)!); if (x=y) x+=y;C (if) x! =y) scanf (%d, &x) else scanf (%d); D, &y) if (x= a &a= 0 &a= n+ 9);S+;Input data: 813. the following three conditional statements (B as

13、integer, S1 and S2 represent the embedded statement)If (b) S1; else S2; if (b=0) S2; else S1; 3 if (B =0 S1; else S2!);Functional equivalence is d.A) the B) and the C II) 1 and 3 D) and the thirdThe sixth chapterThe 1. section is provided with a programInt k=10;While (k=0) k=k-1;The following descri

14、ption is correct C.A) while executes 10 times b) while loop is an infinite loopC) cycle time is not executing statements that form the body of D) to perform a cycle of statements that form the bodyThe following 2. segments, K value is 36.Int k=1, n=263;Dok*=n%10; n/=10; while (n);The general form of

15、 the 3.for statement for for (expression 1; 2 expression; expression 3) statement.The 4.break statement can not be used for any other statements and loops in Switch.5. if the for break statement with a switch structure including a loop, then the break statement is outThe structure of switch.The seve

16、nth chapter1. following the correct description of one-dimensional integer array A is d.A) int a (10); int n=10, an B);C) int n d #define SIZE 10);Scanf (%d, &n); int aSIZE;Int an;2. Description: int a4=0,0; if there is a two-dimensional array a first dimension size is 1.3. if there is a definition:

17、 double x35; the array in the column index of the upper limit of 4.4. dimensional array a m column, in a number of aij elements i*m+j.5。要想从终端把字符串”这本书是“送到字符数组中,应调用函数获取。6。有定义静态字符NAL 8 =“男孩”,Na2 8 =“女”;写一语句比较这两个字符串是否相等,如相等则打印是如果(strcmp(1,2)= = 0)printf(“是”);。第八章1。C语言允许函数值类型缺省定义,此时该函数值的类型是B。一)浮型B)int型C)

18、长型D)双型2。如用数组名作函数调用的实参,传递给形参的是一。一)数组的首地址B)数组第一个元素的值C)数组全部元素的值D)数组元素的个数3。如有以下数组定义和F函数调用语句:a 3 4 ;F(A);则在F函数的说明中,对形参数组阵列的错误定义方式是B。一)f(int数组 6 )B)f(int数组 3 )C)f(int数组 4 )d)f(int数组 2 5 )4。对于函数空隙F1(x,浮y) printf(“%”,x + y);正确的调用语句为B一)F1(3,4);b)F1(3.0,4.0);c)浮Z;Z = F1(3,4);D)浮Z;Z = F1(3.0,4.0);5。在C语言中,函数名代表

19、该函数的入口地址。6。如果函数值的类型与返回值类型不一致,则以函数值类型为准。7以下说法正确的是一。如果在一个函数中的复合语句中定义了一个变量,则该变量一)只在该复合语句中有效B)在该函数中有效C)在本程序范围内均有效D)为非法变量8。全局变量存放在静态存储区中。9。对局部静态变量是在编译时赋初值的。10。凡是函数中未指定存储类型的局部变量,其隐含的存储类别为汽车。11。以下程序的功能是计算1!2!3!4!5!。f(int n) static int f = 1;F = Fn;返回F;main() j;为(J = 1;J = 5;j+)printf(“%d!= %d”,J,F(j);第九章1。

20、预处理命令行都必须以符号#开始。2。宏定义是用宏名代替一个字符串。3。把重力加速度9.8定义为一个符号常量G的语句是#定义G 9.8。4。宏替换不占用运行时间。5语言的编译系统对宏命令的处理是D。C。6。7.8.9.In the running of B in the connection of the program)And the C program in its statement compilingD) before on other components in the source program officially compiled6. if the #define Mod ma

21、cro definition (x, y) x%y is the implementation of the following procedures after the period of output is a.Int Z, a=15, b=100;Z=Mod (B, a); printf (%dn, z+);A) 10 b) 11 C) 6 d) macro definition is not legitimate7. the following program is the result of 5.#define D (R) r*r(main)int x=1, y=2, t;T=D (

22、x+y);Printf (%dn, t);8. in the file contains preprocessor use form, when behind the #include file name (double quotes) enclosed, looking for the included files is B.A) directly according to the standard set in the system directory search modeB) first directory in the search source program, according

23、 to the standard set in the system directory searchC) only search source program directory d) only search the current directoryThe 9. program was quoted in the sin library functions, it should be included in the command file and #include file math.h.The tenth chapterThe pointer variable p 1. define

24、a pointer to a one-dimensional array containing 4 integer elements of the statement is int (*p) 4;.2. if the following statement:Int a4=1,3,5,7, *p;P=&a1;It is + + (*p) 4 is the value of the value of *-p is 1.3. if the definition of int a33, said the correct wording of a11 element address is a.A) *

25、(a+1) +1 b) &a1+1 C) a1+1 * D (a+1) +1)4. if any of the following definition and assignment of int a23 (*p) 3; p=a; the a array I for the j column (if I, J has the correct instructions and assignments) legal reference elements for D address.* (a) * (p+i) +j) b) * (p+i+j) C (p+i) +j d) * (p+i) +j5. f

26、unction max (a, b), and has the function pointer variable p to function max, when using a pointer variable p to call the function, call the method is correct (*p) (a, B).The following 6. B defines p to a function pointer variable.A int p; b) (*p) (int)C) int *p (d); int (*p) N7. if the statement int

27、 *p, a=4; p=&a; a set of options below are representative of the address is d.A, P, a) *&a b) &*a, &a, *p*&p, *p, c) &a d) &a, &*p, P8. if the definition of char *p; p= Hello!, p5 represents the character!.The eleventh chapterThe description of the 1. known student records for:Struct studentint no;C

28、har name20;Char sex;s;The correct assignment of variable s is d.No=123; name = wanghong; sex= m;B scanf (%d%s%c), &no, name, &sex);C) s.well = 123; s.name = wanghong; s.sex = m;(d) scanf (% d% s% c, & s.no, s.name, & s.sex);2.如有以下说明:struct studentint age; int num; studl, * p = & studl;则对结构体变量studl 中

29、的成员age的不正确引用方式为 b.(a) (b) (c) studl.age student.age page (d) (* p).age3.结构体中的成员名 可以 与程序中的变量名相同.4.结构体变量所占内存长度为 结构体各成员的长度之和.综合练习一、阅读1.阅读程序并写出程序的运行结果int i = 9, j = 3;add (int i, int j)return (i + j);main ()int j = 11;printf (i + j =% d, add (i, j); i + j = 202.阅读程序并写出程序的运行结果# include stdio.h # include

30、string.h main ()static char str = swodniw, * p, c1;int i, j, len;len = strlen (str);p = str;for (i = 0, j = len - 1; i j; i + +, j - - - - - - - -)c1 = * (p + i); * (p + i) = * (p + j); * (p + j) = c1;puts (str); windows3.阅读程序并写出程序的运行结果structchar name 10;structint mouth;int day;int year; birthday;st

31、u = , li lin, 9,101979, zhang wei, 1,301980,wang jian, 5,11980;main () int n = 3, i;for (i = 0; i n; i + +)if (stu i. birthday.year = = 1980)printf (% s% d% d% d n, stu i.name, stu i. birthday.mouth,stu i.birthday.day, stu i. birthday.year); zhang wei 1 - 3, 1980wang jian 5 - 1 - 19804.阅读程序并写出运行结果ma

32、in ()int s, i;for (s = 5, i = 0; i 3; i + +, - - - - - - - - s)printf (% d, f (s);f (int x)static int y = 3;int m = 4;return (y + = m + x); 12 20 275.阅读程序并写出运行结果main ()int k = 19;while (c)if (k% 2 = = 0) printf (% 5d, k); k = k - 1; continue;else if (k 5) break;k = k - 3;16 12 8 46.阅读程序并写出运行结果main (

33、)static int x = 0,1,2,3,4,5,6,7,8,9;int s, i, * p;s = 0;p = & x 0;for (i = 1; i 10;i = i + 2)s + = * (p + i);printf (sum =% d, s); sum = 25二、程序填空1.阅读程序, 完成 _ _ _ _ _ _ _ _ _ _ _ 中的内容.有一分数数列: 2 / 1, 3 / 2, 5 / 3 8 / 5.求出数列的前20项之和.main ()int n, t;the float (a = 2, b = 1, sum = 0;for (n = 1; n + +) n =

34、 20; sum = sum + a / bt = a; (a = a + bb = t;printf (sum =% f n, sum);2.阅读程序, 完成 _ _ _ _ _ _ _ _ _ _ 中的内容.该程序按人求平均成绩, 并分行输出各学生的姓名, 各门成绩及平均成绩 (保留2位小数).struct studentchar name 15;int score 3;the float aver;stu = , li lin 75,85,92, zhang wei, 71,89,74, wang jian, 65,75,87;main ()int i, j, the sum;for (

35、i = 0; i 3; i + +)sum = 0;for (j = 0,; j 3; j + +)sum = sum + stu i.score j;stu i.aver = sum / 3;for (i = 0; i 3; i + +)printf (% s:% 6d% 6d% 6d% 8.2f n, stu i.aver);stu i.name, stu i.score 0, stu i.score 1, stu i.score 2三、改错1.改正下面程序中的错误, 使之能统计字符数组s中a、b和其它字符的个数.main ()char s = abcde;int i, a, b, oth

36、er;char c; 增加语句a = 0; b = 0; other = 0;for (i = 0; (c = s i). = 0; i + +)the switch (c)case a: a + +; 增加语句 break;case b: b + +; 增加语句 break;default: other + +;printf (a% d, b% d, other letter% d , (a, b, other);2.改正下列程序的错误, 使之能在任意字符串a中将与字符c相等的所有元素的下标值分别放在整型数组b中.加一条命令 # include stdio.h main ()char a 8

37、0;int i, b 80, d; 加一条语句 k = 0;gets (a);for (i = 0; a i! = 0; i + +)if (a i = = c) b k = i; c + +; 将b k = i; c + +; 改为 b k = i; c + +;for (i = 0; i k; i + +) printf (% 3d , b i);3.下面程序的功能是统计正整数的各位数字中0的个数, 并求各位数字中的最大者请改正错误main ()int n, c, m, t;加两条语句m = 0; c = 0;scanf (% f, n); 将scanf (% f, n);To scanf (%d, &n);DoT=n%10;If (t=0) +c; if (t=0) to if (t=0)Else if (mt) m=t;N/=10 while (n);Printf (%d,%d, C, m);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1