欢迎来到三一文库! | 帮助中心 三一文库31doc.com 一个上传文档投稿赚钱的网站
三一文库
全部分类
  • 研究报告>
  • 工作总结>
  • 合同范本>
  • 心得体会>
  • 工作报告>
  • 党团相关>
  • 幼儿/小学教育>
  • 高等教育>
  • 经济/贸易/财会>
  • 建筑/环境>
  • 金融/证券>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 三一文库 > 资源分类 > DOC文档下载  

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

    • 资源ID:9274781       资源大小:52KB        全文页数:25页
    • 资源格式: DOC        下载积分:6
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录   微博登录  
    二维码
    微信扫一扫登录
    下载资源需要6
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

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

    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 is 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 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 1E5 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, underline 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.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 char<int<double.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;Unsigned 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 + 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 的值为 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 ", & 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 = 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= (a<b)? A:b; if statements equivalent to if (a<b) s=a; else s=b;.8. if the statement int i=5, j=4, k=6; float f; execute f= statement (i<j&&i<k)? I: (j<k)? J:k, f; the value of A.A) 4 b) 6 C) 5 d 5)9. with int x=0, y=1; the following is the value of the expression is 1.(x+*x-= =y) 8-4:y?10. if a definition: int a=5, b=9; printf statement ("%d%c%dn", "a a>b? >": "<", b); after the output is 5<9.The following 11. incorrect if statement is C.A) if (x>y&&x =y b)!); if (x=y) x+=y;C (if) x! =y) scanf (%d, &x) else scanf ("%d"); D, &y) if (x<y) x+; y+;12. if a definition: char a; int c=0, n=0, s=0; the following statement, the 1 is the value of S.Scanf (%c, &a);If (a>= "a" &&a<= "Z" c+);Else if (a>= 0 &&a<= n+ 9);S+;Input data: 813. the following three conditional statements (B as 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 description 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 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 seventh 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: 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)长型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语言中,函数名代表该函数的入口地址。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。预处理命令行都必须以符号#开始。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 macro 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 (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 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 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) * (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. function 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 *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;Char 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 中的成员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 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;stu = , "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.阅读程序并写出运行结果main ()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 ()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 < = 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 (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, other;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 80;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 (m<t) m=t;N/=10 while (n);Printf (%d,%d, C, m);

    注意事项

    本文(c语言作业s(C language s).doc)为本站会员(rrsccc)主动上传,三一文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




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

    三一文库
    收起
    展开