《c语言程序设计》形成性考核作业解答.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
、选择题 1. 3. 《C语言程序设计》作业4解答 假定有struct BOOK {char title[40]; float price;}; struct (A )° A. struct BOOK * x=malloc(book); B. struct BOOK x={C++ Programmi ng,27.0}; C. struct BOOK * x=malloc(sizeof(struct BOOK)); D. struct BOOK **x=book; 假定有 “ struct BOOK {char title[40]; float price;} A. struct BOOK x=book; B. struct BOOK * x=book; C. struct BOOK x=calloc(BOOK); D. struct BOOK *x=BOOK; 为 2. book; ” 表示文件结束符的符号常量为 (C A. eof B. Eof C. EOF BOOK * book;”,则不正确的语句 ,则正确的语句为 (B )。 D. feof 4. C语言中的系统函数fopen()是(D )一个数据文件的函数。 5. 6. 1. A.读取 B.写入 C.关闭 D.打开 从一个数据文件中读入以换行符结束的一行字符串的函数为 A. gets() B. fgets() C. getc() D. fgetc() 向一个二进制文件中写入信息的函数 fwrite()带有(D )个参数。 A. 1 B. 2 C. 3 D. 4 填空题 假定一个结构类型的定义为 struct A {int a, b; struct A * c;}; ” ,则该类型的大小为 12 字节。 2.假定一个结构类型的定义为 struct B{i nt a[5]; char * b;}; ”,则该类型的大小为 24 节° 3.假定一个结构类型的定义为 struct D{i nt a; union {int b; double c}; struct D * d[2];};,则该类 型的大小为 20 字节。 使用的语句表达式为 struct Worker * r= calloc(n, sizeof(struct Worker)); 5?假定要访问一个结构 x中的由a指针成员所指向的对象,则表示方法为 *(x.a) 。 7.6?假定要访问一个结构指针 p所指对象中的b指针成员所指的对象,则表示方法为 *(p-b) 7. 与结构成员访问表达式(*fp).score等价的表达式是 fp-score 。 写出下列每个程序运行后的输出结果 1.#inelude stdio.h 1. #inelude stdio.h struct Worker { char n ame[15]; //姓名 int age; //年龄 float pay; //工资 }; voidmain()structWorkerx={wanghua, 52, 2350};structWorkery,* p;y=x;p=x; void main() struct Worker x={wanghua, 52, 2350}; struct Worker y,* p; y=x; p=x; prin tf(%s %d%6.2f\n,y.name, y.age,y.pay);prin tf(%s %d%6.2f\n,p_name, p-age, p-pay); prin tf(%s %d %6.2f\n,y.name, y.age,y.pay); prin tf(%s %d %6.2f\n,p_name, p-age, p-pay); 2.程序的运行结果是#in clude stdio.hwanghua 52wanghua 522350.002350.00 2. 程序的运行结果是 #in clude stdio.h wanghua 52 wanghua 52 2350.00 2350.00 #in clude stri ng.h struct Worker { char n ame[15];//姓名int age;//年龄float pay;//工资 char n ame[15]; // 姓名 int age; // 年龄 float pay; // 工资 }; void main() { char *t=liout in g; int d=38; float f=493; strcpy(x.name, t); x.age=d; x.pay=f; x.age++; x.pay*=2; printf(%s %d %6.2f\n,x.name, x.age, x.pay); 程序的运行结果是 : liouting 39 9

文档评论(0)

xiaozu + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档