C语言程序设计课程形成性考核册(保留版)_第1页
C语言程序设计课程形成性考核册(保留版)_第2页
C语言程序设计课程形成性考核册(保留版)_第3页
C语言程序设计课程形成性考核册(保留版)_第4页
C语言程序设计课程形成性考核册(保留版)_第5页
已阅读5页,还剩37页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

C 语言程序设计课程形成性考核册 保留版 第一次作业 一 选择题一 选择题 1 A 2 D 3 B 4 D 5 B 6 A 7 C 8 A 9 B 10 C 11 C 12 A 13 B 14 D 15 B 16 D 17 A 二 填空题二 填空题 1 或分号 2 或右花括号 3 4 5 include 6 用户 7 函数头 8 printf 9 void 10 43 18 25 11 warning 12 error 13 0 x19 14 n 15 D 16 72 17 4 18 1 19 4 20 4 21 int 22 double 23 const 24 初始化 25 6 26 7 27 6 25 28 4 29 x 30 y y 1 31 x 32 x y 5 33 ab 则返回 1 若 a b 则返回 0 若 a b 则返回 1 2 求出 a b c 三个数中的最大值并返回 3 计算 1 x 2 x2 3 xn n 1 的值并返回 4 判断 x 是否为一个素数 若是则返回 1 否则返回 0 5 此函数用于把十进制整数 x 转换为十六进制数字串输出 五 根据下列每个题目要求编写程序五 根据下列每个题目要求编写程序 1 void fun4 char a int b int i for i 0 i 0 a 2 double Mean double a M N int m int n int i j double v 0 0 for i 0 i m i for j 0 j n j v a i j v m n return v 3 int FF int a int n if n 1 return a n 1 else return a n 1 FF a n 1 4 include void main int i 0 double s 0 或 int i 1 double s 1 while s 5 s double 1 i printf n d n i 5 include void main int i 0 用 i 作为依次取值偶数的变量 int s 0 用 s 作为累加变量 do i 2 s i i while s 1000 printf n d n i 2 6 include void main int i 用 i 作为计数 循环 变量 int s 0 用 s 作为累加变量 int n printf 输入一个自然数 scanf d for i 1 ib 7 fp score 三 写出下列每个程序运行后的输出结果三 写出下列每个程序运行后的输出结果 1 wanghua 52 2350 00 wanghua 53 2370 00 2 liouting 39 986 00 3 def 58 638 00 四 写出下列每个函数的功能四 写出下列每个函数的功能 1 从键盘输入 n 个 Worker 类型的记录到一维数组 a 中 2 建立一个具有 n 个结点的链表 每个结点的字符串值由键盘输入 链表的 表头指针由函数返回 3 从表头指针 f 指向的 由 IntNode 类型的结点所构成的链表中查找出 data 域的值最小 的结点并返回指向该结点的指针 4 统计出以表头指针为 f 的链表中结点的个数 5 根据从键盘上输入的 n 个整数建立以一个链表 链表中的结点次序与输入值的次序相 反 表头指针由函数返回 6 从键盘上输入一组字符串到 d xxk xuxk1 txt 字符文件中 存入文件时每个字符串后 添加一个换行符 当从键盘上输入结束标志字符串 end 时程序结束 第一次作业 一 选择题 1 在每个 C 语言程序中都必须包含有这样一个函数 该函数的函数名为 A A main B MAIN C name D funtion 2 C 语言原程序文件的缺省扩展名为 A A cpp B exe C obj D C 3 由 C 语言目标文件连接而成的可执行的缺省扩展名为 B A cpp B exe C obj D C 4 程序运行中需要从键盘输入多于一个数据时 各数据之间应使用 D 符号作为分 隔符 A 空格或逗号 B 逗号或回车 C 回车或分号 D 空格或回车 5 每个 C 语言程序的编译错误分为 B 类 A 1 B 2 C 3 D 4 6 设 x 和 y 均为逻辑值 则 x a a a 则执行结束后 a 的值为 C A 12 B 144 C 156 D 288 8 x 0 B const int M2 20 C const M3 10 D const char mark 3 11 带有随机函数的表达式 rand 20的值在 C 区间内 A 1 19 B 1 20 C 0 19 D 0 20 12 当处理特定问题时的循环次数已知时 通常采用 A 循环来解决 A for B while C do while D switch 13 在 switch 语句的每个 case 块中 假定都是以 break 语句结束的 则此 switch 语句 容易被改写为 B 语句 A for B if C do D while 14 for 语句能够被改写为 D 语句 A 复合 B if C switch D while 15 下面循环语句执行结束后输出的 i 值为 B for int i 0 in 2 cout i endl break A n 2 B n 2 1 C n 2 1 D n 1 16 在下面循环 w 语句中内层循环体 S 语句的执行次数为 D for int i 0 i n i for int j i j n j S A n2 B n 1 2 C n n 1 2 D n n 1 2 17 在下面的 do 循环语句中 其循环体被执行的次数为 A int i 0 do i while i i5的相反表达式为 x yb b 5的相反表达式为 a5 by 逻辑值为 false 35 若 x 5 y 10 则 x y 逻辑值为 true 36 假定 x 5 则执行 a x 10 20 语句后 a 的值为 10 37 执行 typedef int DataType 语句后 在使用 int 定义整型变量的地方都可以使用 DataType 来定义整型变量 38 在 switch 语句中 每个语句标号所含保留字 case 后面的表达式必须是 整型 39 作为语句标号使用的 C 保留字 case 和 default 只能用于 switch 语句的定义体中 40 在 switch 语句时 在进行作为条件的表达式求值后 将从某个匹配的标号位置起 向下执行 当碰到下一个标号位置时 停止 不停止 不停止 执行 41 若 do 循环的 尾 为 while i 10 并且 i 的初值为0 同时在循环体不会修改 i 的值 由循环体将被重复执行 10 次后正常结束 42 当在程序执行到 break 语句时 将结束本层循环语句或 switch 语句的执行 43 在程序中执行到 return 语句时 将结束所在函数的执行过程 返回到调用该函 数的位置 44 在程序执行完 主 main 函数调用后 将结束整个程序的执行过程 返回到操 作系统或 C 语句集成开发环境界面窗口 三 写出下列每个程序运行后的输出结果 1 include void main int x 5 switch 2 x 3 case 4 printf d x case 7 printf d 2 x 1 case 10 printf d 3 x 1 break default printf s default n printf s n switch end 输出结果为 11 14 switch end Press any key to continue 2 include void main int i s 0 for i 1 i 6 i s i i printf s d n s 输出结果为 s 91 Press any key to continue 3 include void main int i s1 0 s2 0 for i 0 i 10 i if i 2 s1 i else s2 i printf d d n s1 s2 输出结果为 25 20 Press any key to continue 4 include void main int n 10 y 1 while n y y printf y d n y 输出结果为 y 21 Press any key to continue 5 include void main int f f1 f2 i f1 f2 1 printf d d f1 f2 for i 3 i 10 i f f1 f2 printf d f if i 5 0 printf n f1 f2 f2 f printf n 输出结果为 1 1 2 3 5 8 13 21 34 55 Press any key to continue 6 include include void main int i n for n 2 n 20 n int temp int sqrt n sqrt n 求出 n 的平方根并取整 for i 2 itemp printf d n printf n 输出结果为 2 3 5 7 11 13 17 19 Press any key to continue 7 include include const int M 20 void main int i c2 c3 c5 c2 c3 c5 0 for i 1 i M i if i 2 0 c2 if i 3 0 c3 if i 5 0 c5 printf d d d n c2 c3 c5 输出结果为 10 6 4 Press any key to continue 8 include include const int M 20 void main int i s for i 1 s 0 i 15 i if i 2 0 i 3 0 continue printf d i s i printf d n s 输出结果为 1 5 7 11 13 37 Press any key to continue 第二次作业第二次作业 一 选择题 1 在下面的一维数组定义中 C 语句有语法错误 A int a 1 2 3 B int a 10 0 C int a D int a 5 n 2 在下面的二维数组定义中 C 语句是正确的 A int a 5 B int a 5 C int a 3 1 3 5 2 D int a 10 3 假定一个二维数组的定义语句为 int a 3 4 3 4 2 8 6 则元素 a 1 2 的值为 C A 2 B 4 C 6 D 8 4 假定一个二维数组的定义语句为 int a 3 4 3 4 2 8 6 则元素 a 2 1 的值为 A A 0 B 4 C 8 D 6 5 将两个字符串连接起来组成一个字符串时 选用 C 函数 A strlen B strcap C strcat D strcmp 二 填空题 1 假定一维数组的定义为 char a 8 则该数组所含元素的个数为 8 2 假定一维数组的定义为 char a 8 则该数组所占存储空间的字节数为 32 3 假定二维数组的定义为 int a 3 5 则该数组所占存储空间的字节数为 60 4 假定二维数组的定义为 char a M N 则该数组所所含元素的个数为 M N 5 假定二维数组的定义为 double a M N 则每个数组元素的行下标取值范围在 0 M 1 之间 6 假定二维数组的定义为 double a M N 则每个数组元素的列下标取值范围在 0 N 1 之间 7 使用 typedef char BB 10 50 语句定义 BB 为含有10行50列的二维字符 数组类型 8 存储字符 a 需要占用存储器的 1 个字节空间 9 空字符串的长度为 0 10 存储一个空字符串需要占用 1 个字节 11 字符串 a xxk 数据 的长度为 11 12 用于存储一个长度为 n 的字符串的字符数组的长度至少为 n 1 13 strcmp 函数用于进行两个字符串之间的 大小比较 14 Strcpy 函数用于把一个字符串 复制到 另一个字符数组空间中 15 一个二维字符数组 a 10 20 能够存储 10 个字符串 16 一个二维字符数组 a 10 20 能够存储的每个字符串的长度至多为 19 三 写出下列每个程序运行后的输出结果 1 include void main int a 10 12 39 26 41 55 63 72 40 83 95 int i i1 0 i2 0 for i 0 i 10 i if a i 2 1 i1 else i2 printf d d n i1 i2 输出结果为 6 4 Press any key to continue 2 include include void main int i char a 5 student worker cadre soldier peasant char p1 p2 p1 p2 a 0 for i 0 i0 p1 a i if strcmp a i p2 0 p2 a i printf s s n p1 p2 输出结果为 worker cadre Press any key to continue 3 include int a 10 4 5 6 15 20 13 12 7 8 9 void main int i s0 s1 s2 s0 s1 s2 0 for i 0 i 10 i switch a i 3 case 0 s0 a i break case 1 s1 a i break case 2 s2 a i break printf d d d n s0 s1 s2 输出结果为 42 24 33 Press any key to continue 4 include void main char a abcdbfbgacd int i1 0 i2 0 i 0 while a i if a i a i1 if a i b i2 i printf d d d n i1 i2 i 输出结果为 2 3 11 Press any key to continue 5 include void main int a 3 4 1 2 7 8 5 6 10 6 9 12 3 4 int m a 0 0 int ii 0 jj 0 int i j for i 0 i 3 i for j 0 jm m a i j ii i jj j printf d d d n ii jj a ii jj 输出结果为 2 1 12 Press any key to continue 6 include void main int a b for a 1 b 2 b 50 printf d d a b a a b b a b printf n 输出结果为 1 2 3 5 8 13 21 34 Press any key to continue 四 写出下列每个函数的功能 1 include int SA int a int b if a b return 1 else if a b return 0 else return 1 函数功能为 根据实参 a 大于 等于或小于实参 b 返回1 0或 1 2 include int SC int a int b int c if a b if b a return c 函数功能为 返回实参 a b c 中的最大数 3 double SF double x int n n 为大于等于0的整数 double p 1 s 1 for i 1 i n i p x s p i 1 return s 函数功能为 计算 x x2 2 x3 3 xn n 1 的值 4 include int SC int x int a int sqrt x int i 2 while i a if x i 0 break i if i 0 return 0 else return 1 函数功能为 判断一个整数是否是素数 5 include void trans int x char a 10 int i 0 rem do rem x 16 x x 16 if rem0 printf c a i printf n 函数功能为 将一个整数化成十六进制数 五 根据下列每个题目要求编写程序 1 编写一个函数 函数头格式为 void fun4 char a int b 分别求出由字符指针 a 所指向的字符串中包含的每种十进制数字出现的次数 把统计结果保存在数组 b 的相应元 素 include void fun4 char a int b do if a 0 while a void main char a 9888 int b 10 0 fun4 a b for int i 0 i 10 i printf d b i 2 编写一个函数 函数头格式为 double Mean double a M N int m int n 要求返回二维数组 a m n 中所有元素的平均值 假定在计算过程是采用变量 v 存放平均值 include const int M 2 N 3 double Mean double a M N int m int n double v 0 for int i 0 i m i for int j 0 j n j v a i j return v m n void main double a 2 3 1 2 3 4 5 6 printf lf n Mean a 2 3 3 编写一个递归函数 int FF int a int n 求出数组 a 中所有元素 n 个元素 之积并返回 include int FF int a int n int mul 1 if n 1 mul a 0 else mul a n 1 FF a n 1 return mul void main int a 6 1 2 3 4 5 6 printf d n FF a 6 4 编写一个主函数 利用 while 循环 求出并显示满足不等式 1 1 2 1 3 1 n 5的最小 n 值 include void main double sum 0 int n 1 while true if sum 1 double n 5 break else sum 1 double n n printf d lf n n sum 5 编写一个主函数 求满足不等式22 42 n2 1000的最大 n 值 假定分 别用 i 和 s 为取偶数值和累加值的变量 并限定使用 do 循环编程 include void main int s 0 i 2 do s i i if s i 2 i 2 1000 break else i 2 while true printf i d s d i s 6 编写一个主函数 计算并输出 n 的值 其中 n 值由键盘输入 include void main int s 0 n printf 请输入 n 的值 scanf d for int i 1 ib 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 年龄 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 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 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

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论