




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Comment 别别别别别别别1 应加入此 4 字 否则 D 亦对 C 语言程序设计形成性作业三语言程序设计形成性作业三 一 一 选择题选择题 1 在下面的 C 函数声明语句存在语法错误 A AA int a int b B AA int int C AA int a int b D AA int a int 2 在下面的 C 不能作为函数的返回类型 A void B int C new D long 3 下面正确的函数原型语句是 B A int Function void a B void Function int C int Function a D void int double a 4 函数调用 func exp1 exp2 exp3 exp4 exp5 中所含实参的个数为 B 个 A 1 B 2 C 4 D 5 5 下面的标识符中 C 是文件级作用域 A 函数形参 B 语句标号 C 外部静态类标识符 D 自动类标识符 6 下面的标识符中 B 具有全局级作用域 A 函数形参 B 全局变量 C 内部静态类标识符 D 自动变量符 7 假定 p 是一个指向 float 型数据的指针 则 p 1 所指数据的地址比 p 所指数据的地址大 C 字节 A 1 B 2 C 4 D 8 8 假定 a 为一个字符数组名 则 a 8 的地址比该数组的首地址大 B 个字节 A 4 B 8 C 16 D 32 9 假定 a 为一个数组名 则下面的 B 表示有错误 A a i B a C a D a 1 10 用 calloc 函数创建具有 10 个整型元素的一维数组的正确语句是 C A int p calloc 10 2 B int p callo 10 C int p calloc 10 4 D int p malloc 10 11 假定变量 m 定义为 int m 7 则定义 p 的正确语句为 B A int p B int p C int D int p m 12 假定 k 是一个 double 类型的变量 则定义指向 k 的变量 p 的正确语句为 D A double p B double p C double D char p Thank you 13 假定一条定义语句为 int a 10 x pa a 若要把数组 a 中下标为 3 的元素赋值给 x 则不正确的语句 为 D A x pa 3 B x a 3 C a a 3 D x pa 3 14 假定有定义 int b 10 int pb 则不正确的赋值语句为 D A pb b B pb C pb b 2 D pb b 5 15 假定指针变量 p 定义为 int p new int 100 要释放 p 所指向的动态内存 应使用语句 A A delete p B delete p C delete D delete p 16 假定指针变量 p 定义为 int p calloc 30 sizeof int 要释放 p 所指向的动态内存 应使用语句 D A delete p B deldete p C free p D free p 二 填空题二 填空题 1 在 C 语言中 一个函数由函数头和 函数体 组成 2 在函数外定义的变量称为全局变量 若没有被初始化则系统隐含对它所赋的初值为 0 3 如果一个函数只允许同一程序文件中的函数调用 则应在访函数定义前加上的 C 保留字为 static 4 如果一个函数直接或间接地调用自身 这样的调用被称为 递归 调用 5 调用系统函数时 要先使用 include 命令包含该函数的原型语句所在 头 文件 6 函数形参的作用域是该函数的 函数体 7 假定 p 所指对象的值为 25 p 1 所指对象的值为 46 则 p 的值为 25 8 假定 p 所指对象的值为 25 p 1 所指对象的值为 46 则 p 的值为 46 9 假定 p 所指对象的值为 25 p 1 所指对象的值为 46 则执行 p 语句后 p 所指对象的值为 46 10 假定 a 是一个指针数组 则 a 1 所指对象的地址比 a 地址大 4 i 字节 11 若要把一个整型指针 p 转换为字符指针 则采用的强制转换表达式为 char p 12 假定一个数据对象为 int 类型 则指向该对象的指针类型为 int 13 假定 p 是一个指向整数对象的指针 则用 break case B case b printf GG break case C case c printf PP break default printf BB break void main char a1 b a2 C a3 f SB a1 SB a2 SB a3 SB A printf n GG PP BB WW 2 include include double SD int a int b char op double x switch op case x a b break case x a b break case x a b break case if b x double a b else exit 1 break default 运算符错 n exit 1 return x void main int x 20 y 8 printf 3 2lf SD x y printf 3 2lf SD x y printf 3 2lf SD x y 12 00 160 00 3 50 3 include void WF int x int y x x y y x y printf subs x y d d n x y void main int x 18 y 23 printf main x y d d n x y WF x y x 2 x printf main x y d d n x y main x y 18 23 subs x y 41 64 main x y 36 23 4 include include void fun char ss void main char s 15 567891234 fun s printf s n s void fun char ss int i n strlen ss for i 0 i n 2 i char c ss i ss i ss n 1 i ss n 1 i c 432198765 5 include void InsertSort int a int n int i j x for i 1 i 0 j 为 x 顺序向前寻找合适的插入位置 if x a j a j 1 a j else break a j 1 x void main int i int a 6 20 15 32 47 36 28 InsertSort a 6 for i 0 i 6 i printf d a i printf n 47 36 32 28 20 15 6 include void main int a 8 3 5 7 9 11 13 15 17 int i p a for i 0 i 8 i printf 5d p if i 1 4 0 printf n 3 5 7 9 11 13 15 17 7 include int LA int a int n int i s 0 for i 0 i n i s a i return s void main int a 5 10 15 20 25 30 int b LA a 4 int c LA a 2 3 printf d d n b c 50 60 8 include int LB int a int n int i s 1 for i 0 i n i s a return s void main int a 1 2 3 4 2 4 5 2 int b LB a 4 LB printf b d n b b 184 四 写出下列每个函数的功能四 写出下列每个函数的功能 1 include int WB int a int n int x for int i 0 i n i if a i x return 1 return 0 从数组 a 中顺序查找值为 x 的元素 若查找成功则返回 1 否则返回 0 2 include int WC int a int n int k int c 0 for int i 0 i k c return c 统计出数组 a 中大于等于值为 k 的元素个数并返回 3 include include include const int N 10 int ff int x int y int z printf d d x y scanf d if x y z return 1 else return 0 void main int i a b c 0 srand time 0 初始化随机数系列 for i 0 i N i a rand 20 1 rand90 函数产生 0 32767 之间的一个随机数 b rand 20 1 c ff a b printf 得分 d n c 10 让计算机产生出 10 道操作数为 20 以内随机整数的加法题供用户计算 每道题 10 分 计算完成后打印出得 分 4 int fun6 int m int n int b 2 if m b else if m b 0 else return fun6 m n b 一个递归函数过程 求出两个自然数 m 和 n 的最小公倍数 5 include include void LI int n int a int malloc n sizeof int int i for i 0 i 0 i printf d a i printf n free a 把从键盘上输入的 n 个整数按与输入的相反次序显示出来 6 include int LK double a int n Comment 别别别别别别别2 理论值 用 sizeof D 得到的结果是 24 说明编译 系统采用的结构成员对齐方式是 8 个 字节 double s 0 int i m 0 for i 0 i n i s a i s n for i 0 i s m return m 求出并返回数组 a 的 n 个元素中大于等于平均值的元素个数 答案为隐藏文字 一 一 选择题选择题 2 假定有 struct BOOK char title 40 float price struct BOOK book 则不正确的语句为 A A struct BOOK x malloc book B struct BOOK x C Programming 27 0 C struct BOOK x malloc sizeof BOOK D struct BOOK x 3 假定有 struct BOOK char title 40 float price book 则正确的语句为 B A struct BOOK x B struct BOOK x C struct BOOK x calloc BOOK D struct BOOK x BOOK 3 表示文件结束的符号常量为 C A eof B Eof C EOF D feof 4 C 语言中系统函数 fopen 是 D 一个数据文件的函数 A 读取 B 写入 C 关闭 D 打开 5 从一个数据文件中读入以换行符结束的一行字符串的函数为 B A gets B fgets C getc D fgetc 6 向一个二进制文件写入信息的函数 fwrite 带有 D 参数 A 1 B 2 C 3 D 4 二 填空题二 填空题 1 假定一个结构类型的定义为 struct A int a b A c 则该类型的大小为 12 字节 2 假定一个结构类型的定义为 struct B int a 5 char b 则该类型的大小为 24 字节 3 假定一个结构类型的定义为 struct D int a union int b double c struct D d 2 则该类型的大小为 20 字节 4 假定要动态分配一个类型为 struct Worker 的具有 n 个元素的数组 并由 r 指向这个动态数组 则使用语 句的表达式为 struct Worker r Worker malloc n sizeof Worker 5 假定要访问一个结构 x 中的由 a 指针成员所指向的对象 则表示方法为 x a 6 假定要访问一个结构指针 p 所指向对象中的 b 指针成员所指的对象 则表示方法为 p b 7 与结构成员访问表达式 fp score 等价的表达式是 fp score 三 写出下列每个程序运行后的输出结果三 写出下列每个程序运行后的输出结果 1 include struct Worker char name 15 姓名 int age 年龄 float pay 工资 void main struct Worker x wanghua 52 23 50 struct Worker y p y x p printf s d 6 2f n y name y age y pay printf s d 6 2f n p name p age p pay 输出结果为 wanghua 52 23 50 wanghua 52 23 50 Press any key to continue 2 include include struct Worker char name 15 姓名 int age 年龄 float pay 工资 void main struct Worker x char t louting 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 输出结果为 louting 39 986 00 Press any key to continue 3 include include struct Worker char name 15 姓名 int age 年龄 Comment 别别别别别别别3 float pay 工资 int Less struct Worker r1 struct Worker r2 if r1 age r2 age return 1 else return 0 void main struct Worker a 4 abc 25 420 def 58 638 ghi 49 560 jkl 36 375 struct Worker x a 0 int i for i 1 i 4 i if Less x a i x a i printf s d 6 2f n x name x age x pay 输出结果为 def 58 638 00 Press any key to continue 四 写出下列每个函数的功能四 写出下列每个函数的功能 1 void QA struct Worker a int n int i for i 0 i n i scanf s d f 假定结构 struct Worker 的定义如下 include include include struct Worker char name 15 姓名 int age 年龄 float pay 工资 函数功能为 输入 struct Worker 类型的对象 a n 的各个元素的值 2 struct StrNode QB int n StrNode f p if n 0 return NULL Comment 别别别别别别别4 VC 6 0 不 能将 void 赋值给其它类型 必须强 制转换 f StrNode malloc sizeof struct StrNode scanf s f name p f while n p p next StrNode malloc sizeof struct StrNode scanf s p name p next NULL return f 假定结构 struct StrNode 的定义如下 struct StrNode char name 5 struct StrNode next 函数功能为 建立一个具有 n 个结点 每个结点的类型是 StrNode 的链表 3 struct IntNode FindMax struct IntNode f struct IntNode p f if f return NULL f f next while f if f data data p f f f next return p 假定结构 struct StrNode 的定义如下 struct IntNode int data struct IntNode next 函数功能为 在一个具有 n 个结点 每个结点的类型是 IntNode 的链表中寻找 data 值最大的结点 4 int Coun
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 钟表设计师转正考核试卷及答案
- 电火花线切割机床操作工岗位操作规程考核试卷及答案
- 果菜种植气候适应性评估报告
- 律师事务所实习协议样本模版
- 塑料制品成型制作工标准化作业考核试卷及答案
- 接口行为一致性测试-洞察及研究
- 2025-2030中国数据中心绿色节能技术应用与PUE达标路径
- 2025-2030中国快锁接头行业区域市场差异化发展报告
- 2025-2030中国共享居住空间保险产品设计与风险分担方案
- 2025-2030中国公寓行业客户投诉处理与服务质量提升
- 2025文具用品采购合同范本格式
- 电气检修生产安全培训课件
- 2025天津津南国有资本投资运营集团有限公司及实控子公司招聘工作人员招聘5人考试模拟试题及答案解析
- 营造清朗空间+课件-2025-2026学年(统编版2024)道德与法治八年级上册
- 2025年遴选财务岗考试题及答案
- 《2025新版检验检测机构管理评审报告》
- 移动与酒店合作合同协议
- excel操作考试题及答案
- 项目安全管理实施细则
- 车间偷盗行为管理办法
- 2025劳动教育考试试题及答案
评论
0/150
提交评论