




已阅读5页,还剩16页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C C 语言程序设计语言程序设计 一 选择题一 选择题 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 ib 7 与结构成员访问表达式 fp score 等价的表达式是 fp score 三 写出下列每个程序运行后的输出结果 1 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 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 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 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 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 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 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 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 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 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 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 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 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 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 1 include void SB char ch switch ch case A case a printf WW 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 输出结果为 GGPPBBWW Press any key to continue 2 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 2 50 Press any key to continue 3 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 Press any key to continue 4 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 Press any key to continue 5 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 Press any key to continue 6 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 Press any key to continue 7 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 Press any key to continue 8 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 Press any key to continue 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 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 2 include int SC int a int b int c if a b if b a return c 函数功能为 返回实参 a b c 中的最大数 3 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 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 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 1 include int WB int a int n int x for int i 0 i n i if a i x return 1 return 0e 函数功能为 根据整型数组元素中是否能找到整数 x 返回1或0 2 2 include int WC int a int n int k int c 0 for int i 0 i k c return c 函数功能为 返回数组中前 n 个其值大于等于 k 的元素之和 3 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 函数功能为 函数 ff 让两个数相加 要求输入其和 判断结果是否正确 在主函数中用随机函数产生两个20以 内的随机整数 通过10次调用这个函数 算对一次得10分 计算所得分 4 4 int fun6 int m int n int b 2 if m b else if m b 0 else return fun6 m n b 函数功能为 此函数带有一个默认参数 若使用默认值 则通过递归调用 返回前2参数的最小公倍数 不使用默认值时 若最后一个参数不小于前2个参数 则返回前2参数之乘积 否则 通过递归调用 返回前2参数最小公倍数的 n 倍数 5 5 include include void LI int n int a int 电脑商场特别版2 malloc n sizeof int int i for i 0 i 0 i printf d a i printf n free a 函数功能为 将从键盘输入的 n 个整数逆序输出 6 6 include int LK double a int n 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 函数功能为 求不小于数组元素之平均值的各元素之和 前 n 个 五 根据下列每个题目要求编写程序五 根据下列每个题目要求编写程序 1 1 编写一个函数 函数头格式为编写一个函数 函数头格式为 void void fun4 charfun4 char a a intint b b 分别求出由字符指针 分别求出由字符指针 a a 所指所指 向的字符串中包含的每种十进制数字出现的次数 把统计结果保存在数组向的字符串中包含的每种十进制数字出现的次数 把统计结果保存在数组 b b 的相应元素 的相应元素 include void fun4 char a int b do if a 0 while a void main char a 122333444499888 int b 10 0 fun4 a b for int i 0 i 10 i printf d b i 2 2 编写一个函数 函数头格式为编写一个函数 函数头格式为 double double Mean doubleMean double a M N a M N intint m m intint n n 要 要 求返回二维数组求返回二维数组 a m n a m n 中所有元素的平均值 假定在计算过程是采用变量中所有元素的平均值 假定在计算过程是采用变量 v 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
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 办公室装修合同书样本6篇
- 行业云平台架构-洞察及研究
- 停车场道闸施工合同4篇
- 臭氧与紫外线辐射-洞察及研究
- 部队卡车的维护与保养
- 四川省绵阳第一中学2025-2026学年高三上学期入学考试数学试题含答案
- 星系活动星系核-洞察及研究
- 部门车间级安全培训课件
- 医药退货管理创新-洞察及研究
- 达州市安全培训公司课件
- 2025-2026学年人民版小学劳动技术六年级上册教学计划及进度表
- 新学期三年级班主任工作计划(16篇)
- 接种疫苗预防流感课件
- 游戏体验寻规律(教学设计)-2024-2025学年人教版(2024)小学信息技术五年级全一册
- 基于plc的恒压供水控制系统设计
- 环保设备加工处理方案(3篇)
- 《成人重症监护病房口腔护理专家共识》解读课件
- 2025中小学生法制知识竞赛题库及答案
- 恶性间皮瘤护理查房
- 2025新版劳动合同范本
- 2025年中学无线电知识竞赛题库
评论
0/150
提交评论