




已阅读5页,还剩26页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第一章第一章 1 2 有三个数有三个数 A B C 设计算法 求三个数中最大的数并输出 设计算法 求三个数中最大的数并输出 可用自然 可用自然 语言或流程图表示 语言或流程图表示 include void main int a b c max printf please input three numbers n scanf d d d max a if b a max b if c max max c printf the answer is d n max 1 3 设计算法 求设计算法 求 N 个整数的平均值 个整数的平均值 include void main int N i float aver a s 0 printf please input the amount of the number n scanf d for i 0 i N i printf please input the number n scanf f s s a aver s N printf the average is f aver 第二章第二章 1 填空题填空题 换行 回车 整型 变量 整型 6 2 5 2 选择题选择题 A A A B D C C D C D B D B D 3 答案 6 0 6 答案 8 10 16 答案 3 答案 6 答案 1 答案 261 答案 16 答案 0 4 编程题编程题 输入长方形的长和宽 输出长方形的周长和面积 include void main int a b l s scanf d d l a b 2 s a b printf d d l s 输入一个字符 输出其 ASCII 代码 include void main char a printf please input the char scanf c printf the ASCII is d a 输入 3 个整数 计算并输出它们的平均值 include void main int a b c float aver scanf d d d aver float a b c 3 printf f aver 已知整型变量 a b c 的值 根据以下算式编写程序求 y 的值 y 3 8 b2 ac 6a include include void main int a b c printf please input the num of a b c scanf d d d printf the y is f 3 8 pow b 2 a c 6 a 5 设设 a 和和 n 已定义为整型变量 已定义为整型变量 a 12 求下面表达式运算后 求下面表达式运算后 a 的值 的值 a a 24 a 2 10 a 2 3 60 a a a 0 a n 2 n 的值等于 5 0 a a a a 0 第三章 1 选择题选择题 1 C 2 C 3 C4 D5 D 二 填空题二 填空题 1 f 2 s 3 12 56 789 4 6e 16 5 1 1 3 三 编程题三 编程题 1 编写一个程序 从键盘上输入 3 个数 求其和并输出 include void main int a b c d printf please input the num of a b c scanf d d d d a b c printf the sum of a b and c is d d 2 输入一个正整数 分别输出它的八进制和十六进制数形式 include void main int m printf please input the m scanf d printf n ba jin zhi shu zhi shi o m printf n shi liu jin zhi shu zhi shi x m 3 编程把 11325 秒转换成 小时 分钟 秒 的形式 include void main int a 11325 int h m s h a 3600 m a 3600 60 s a 3600 60 printf d d d h m s 4 编程序 求 a b 的值 a b 为任意数 本题可调用求绝对值的函数 fabs 此函数包含在 math h 文件中 include include void main double a b printf please input the num of a and b scanf lf lf printf n a b lf a fabs b 5 编程序 求平面上两点之间的距离 设第 1 个点的坐标为 x1 y1 第 2 点的坐标为 x2 y2 则这两个点的距离为 d 22 1212 xxyy include include void main float x1 y1 x2 y2 d printf n shu ru di 1 ge dian de zuo biao scanf f f printf n shu ru di 2 ge dian de zuo biao scanf f f d sqrt pow x1 x2 2 pow y1 y2 2 printf n ju li d wei f d 第四章 一 阅读程序 回答问题一 阅读程序 回答问题 1 答案 1 2 答案 6 3 B 4 答案 6 5 答案 8 6 答案 2 7 答案 k 11 二 填空二 填空 1 答案 a b 或 b a 或 a b 或 a b 或 b a 2 答案 1 0 2 0 3 答案 1 max y 2 max z 4 答案 1 m 2 1 2 m 2 0 三 编程三 编程 1 输入一个整数 判断其为奇数还是偶数 include void main int a printf Please input an integer scanf d if a 2 0 printf ni shu ru de shu d shi ou shu n a else printf ni shu ru de shu d shi ji shu n a 2 编写一个程序 实现功能是 输入一个实数 按 1 输出此数的相反数 按 2 输出此数的平方根 按 3 输出此数的平方 include include void main double f int a printf qing shu ru yi ge shu scanf f printf n qing shu ru 1 huo 2 huo 3 n printf n an 1 shu chu xiang fan shu printf n an 2 shu chu ping fang gen printf n an 3 shu chu ping fang scanf d if a 1 printf f n f else if a 2 printf f n sqrt f else if a 3 printf f n f f else printf shu ru cuo wu 3 输入字符 输出其类型 ASCII 值小于 32 的为控制字符 在 0 和 9 之间 的为数字 在 A 和 Z 之间为大写字母 在 a 和 z 之间为小写字母 其余则 为其它字符 include void main char a scanf c if a0 printf this is a Control Character if a 0 else printf this is an other character 4 输入某年某月某日 判断这一天是这一年的第几天 include void main int a b c k s 0 printf qing shu ru nian yue ri scanf d d d if a 4 0 else k 28 switch b case 12 s 30 case 11 s 31 case 10 s 30 case 9 s 31 case 8 s 31 case 7 s 30 case 6 s 31 case 5 s 30 case 4 s 31 case 3 s k case 2 s 31 case 1 s c printf ni shu ru de shu shi zhe nian de di d tian s 第五章 一 单选题一 单选题 1 C2 C 3 D 4 C5 B 6 C7 A8 D 9 C 10 C 二 写程序运行结果二 写程序运行结果 1 答案 1 2 3 2 答案 52 3 答案 s 6 4 答案 1 2 5 答案 a 16 y 60 6 答案 6 三 程序填空三 程序填空 1 答案 1 cx getchar 2 front 3 cx 2 答案 1 s 0 2 m n 0 3 m s 3 答案 1 j 1 2 k 6 4 答案 1 50 2 n 2 3 h 2 5 答案 1 a 2 i n 3 t 10 四 程序改错四 程序改错 1 答案 1 int n k 0 2 k k 10 n 10 2 答案 1 for i 0 i 10 i 2 j 3 0 3 答案 1 double k 1 t 1 2 k k 1 t 4 答案 1 i 2 2 k 5 答案 1 h float 5 2 n 2 a a h 五 编写程序五 编写程序 1 编一程序 将 2000 年到 3000 年中的所有闰年年份输出并统计出闰年的总年 数 要求每 10 个闰年放在一行输出 include void main int year k 0 for year 2000 year 3000 year if year 4 0 printf 6d year if k 10 0 printf n printf nrun nian de zong nian shu shi d k 2 若有如下公式 试根据上述公式编程计算 的近似值 精确到 10 6 include include void main float pi a b int i 1 a 0 b 1 while b 0 b 1 float i i a b i pi sqrt 6 a printf f n pi 3 用 0 9 之间不同的 3 个数构成一个 3 位数 统计输出共有多少种方法 include void main int i 0 j 0 k 0 n 0 for i 1 i 10 i for j 0 j 10 j if i j continue for k 0 k 10 k if i k j k continue n printf d n 4 找出 1 99 之间的全部同构数 同构数是这样一组数 它们出现在平方数的 右边 例如 5 是 25 右边的数 25 是 625 右边的数 5 和 25 都是同构数 include void main int i j k k 10 for i 1 i 100 i if i 10 k 100 j i i if j k i printf d t i 5 猴子吃桃问题 猴子第 1 天摘下若干个桃子 当即吃了一半 还不过瘾 又 多吃了个 第 2 天又将剩下的桃子吃掉一半 又多吃了一个 以后每天都吃 了前一天剩下的一半零一个 到第 10 天再想吃时 只剩下一个桃子了 问 第 1 天共摘多少个桃子 include void main int day x x 1 for day 1 day 9 day x x 1 2 printf di yi tian hou zi zhai le d ge tao zi x 6 打印以下图形 include void main int i j k for i 1 i 4 i for j 1 j 4 i j printf printf for j 1 j i 1 j printf printf n 7 百钱百鸡问题 公鸡五元一只 母鸡三元一只 鸡雏一元三只 若用 100 元 买 100 只鸡 可买公鸡 母鸡和鸡雏各多只 include void main int i j k for i 0 i 100 5 i for j 0 j 100 3 j for k 0 k 100 k if k 3 0 continue if 5 i j 3 k 3 100 8 一个正整数与 3 的和是 5 的倍数 与 3 的差是 6 的倍数 编写一个程序求符 合条件的最小数 include void main int k 1 while k 3 5 0 printf d k 9 从键盘输入 20 个整型数 统计其中负数个数并求所有正数的平均值 include void main int a i j 0 k 0 float s 0 printf qing shu ru 20 ge shu for i 1 i 20 i scanf d if a 0 j s a s s float j printf fu shu de ge shu shi d n k printf zhe shu de ping jun zhi shi f n s 10 父亲今年 30 岁 儿子 6 岁 经过多少年后 父亲的年龄是儿子的两倍 include void main int i j k i 30 j 6 k 0 while i k j k 2 k printf d k 第六章 一 选择题一 选择题 1 C 2 C 3 D 4 C 5 C 6 B 7 D 8 A 二 填空题二 填空题 1 答案 b 0 2 答案 15 三 三 编程题编程题 1 编写一个求 x 的 y 次方的函数 include int func int x int y void main int a b c printf please input the two numbers n scanf d d c func a b printf the answer is n printf d n c int func int x int y int i s 1 for i 1 i y i s s x return s 2 编写函数 要求去掉字符串中所有空格 include include void f char s int i j i j 0 while s i if s i s j s i i s j 0 void main char s 80 gets s f s puts s 3 编写函数 判断一个字符串是否是回文 如是返回 1 否则返回 1 回文是 指这个字符串逆置后不变 如 aba 就是回文 include include int f char s int n int i f f 1 i 0 while f break i return f void main char s 80 gets s if f s strlen s 1 printf n Yes else printf n No 4 编写函数 fun 求 1 2 3 n 的和 在 main 函数中由键盘输入 n 值 并 输出运算结果 include int fun int n void main int n c printf please input the number n scanf d c fun n printf the answer is n printf d n c int fun int n int i a s s 1 a 0 for i 1 i n i s s i a a s return a 5 编写两个函数 分别求两个整数的最大公约数和最小公倍数 用主函数调用 这两个函数并输出结果 两个整数由键盘输入 include int func int x int y int fun int x int y void main int x y c d printf please input the two numbers n scanf d d c func x y d fun x y printf the answer is n printf zui da gong yue shu shi d n c printf zui xiao gong bei shu shi d d int func int x int y int t t x y while t x y y t t x y return y int fun int x int y return x y func x y 第七章 1 选择题选择题 1 D 2 B 3 D 4 D 5 A 二 阅读程序写出结果二 阅读程序写出结果 1 答案 1 2 答案 12345 3 答案 t M 4 答案 7078 9198 三 程序填空三 程序填空 1 答案 1 i 2 i 1 3 i 2 答案 1 i 9 2 i 9 3 i 3 0 四 程序改错四 程序改错 1 答案 1 int a 3 0 2 for i 1 i 3 i a 0 a 0 a i 2 答案 1 for i 0 i d i 2 t 2 d 0 3 scanf s s 五 程序问答五 程序问答 1 答案 1 升序 2 1 2 3 4 5 5 6 7 8 9 2 答案 1 33 33 27 22 12 11 1 8 2 8 1 11 12 22 27 33 33 六 编程六 编程 1 在一组数中找出最大与最小值之差 include void main int a 10 i x y printf please input the number n for i 0 i 10 i scanf d x a 0 y a 0 for i 1 ix x a i if a i y y a i printf the answer is d x y 2 用选择法将一组整数按降序排序 include void main int a 10 i j k t printf please input the numbers n for i 0 i 10 i scanf d for i 0 i 8 i k i for j i 1 ja k k j t a k a k a i a i t for i 0 i 9 i printf d a i 3 在一个按升序排列的数组中插入一个数 使数组仍有序 include void main int a 7 3 5 7 9 11 23 int b i k scanf d a 6 b i 5 while b 0 a i 1 a i a i b i printf cha ru hou de shu zu n for i 0 i 7 i printf d a i 4 用 顺序 查找法 在一组数中查找一个值为 K 的元素 若有 输出 YES 若 无 输出 NO include void main int a 10 i j k printf please input the numbers n for i 0 i 10 i scanf d printf please input the aim number n scanf d for i 0 i9 printf NO n else printf YES n 5 输出以下形式的图案 include void main int i j for i 1 i 4 i for j 1 j i 1 j printf for j 1 j 9 2 i j printf printf n 6 将一个数组按逆序重新存放在该数组中 include void main int a 10 i t printf please input the numbers n for i 0 i 10 i scanf d for i 0 i 10 2 i t a i a i a 10 1 i a 10 1 i t for i 0 i 10 i printf d a i 7 打印一个 5 行的杨辉三角形 include void main int a 5 5 0 i j for i 0 i 4 i a i 0 a i i 1 for i 2 i 4 i for j 1 j i j a i j a i 1 j a i 1 j 1 for i 0 i 4 i for j 0 j i j printf 3d a i j printf n 8 用二维字符数组存储下列图形并输出 include void main char c 5 5 0 int i j for i 0 i 5 i for j i j 5 j c i j for i 0 i 5 i for j 0 j 5 j printf c c i j printf n 9 计算二维数组主对角线元素之和 include void main int a 3 3 i j x printf please input the numbers n for i 0 i 3 i for j 0 j 3 j scanf d x 0 for i 0 i 3 i x x a i i printf the answer is d n x 10 用 折半 查找法 在一组按降序排列的数中查找一个值为 K 的元素 若有 输出 YES 若无 输出 NO include void main int a 10 10 9 8 7 6 5 4 3 2 1 l r m k printf please input the numbers n scanf d l 0 r 9 m 1 r 2 while la m r m 1 else l m 1 m l r 2 if l r printf n YES else printf n NO 11 编写一个程序计算一个字符串的长度 不使用库函数 include include void main char s 80 int n 0 gets s while s n n printf length d n 12 比较两个字符串 S1 S2 的大小 不使用库函数 若 S1 S2 输出 1 若 S1 S2 输出 0 若 S1 S2 输出 1 include include void main char s1 80 s2 80 int i n gets s1 gets s2 i 0 while s1 i if s1 i s1 i s2 i n 1 if s1 i printf jie guo shi d n 13 用 冒泡 法将一组数按升序排序 include void main int a 10 i j x for i 0 i 10 i scanf d for j 0 j 9 j for i 0 ia i 1 x a i a i a i 1 a i 1 x for i 0 i 10 i printf 4d a i 14 在一个二维数组中形成并输出如下矩阵 1 1 1 1 1 2 1 1 1 1 3 2 1 1 1 4 3 2 1 1 5 4 3 2 1 include void main int a 5 5 int i j for i 0 i 5 i for j 0 j 5 j if i j a i j 1 else a i j i j 1 for i 0 i 5 i for j 0 j 5 j printf 2d a i j printf n 15 有一个 3 4 的矩阵 求其中的最大元素的值及位置 include void main int a 3 4 i j x l r for i 0 i 3 i for j 0 j 4 j scanf d x a 0 0 l r 0 for i 0 i 3 i for j 0 jx x a i j l i r j printf Max number is d position is d d n x l r 第九章 一 选择题一 选择题 1 D 2 B 3 D 二 写出以下程序的运行结果二 写出以下程序的运行结果 1 答案 6 2 答案 6 3 答案 2 3 4 答案 6 5 答案 Zhao m 85 90 3 改错题改错题 1 答案 1 最后加分号 2 改为 scanf d d 3 改为 printf The point you input is x d y d pt x pt y 2 答案 1 改为 struct People peo 2 改为 scanf c 3 改为 scanf c 4 改为 scanf s 5 改为 printf The d People s name is s sex c position s age d n i 1 peo i name peo i sex peo i position peo i age 四 编程题四 编程题 1 设计一个通信录的结构体类型 并画出该结构体变量在内存的存储形式 struct photonote char name 20 char number 20 2 用结构体变量表示矩形 编写矩形面积函数 矩形周长函数 输入矩形长 宽函数 输出矩形长宽函数 输入矩形的长宽并进行面积和周长的计算 include struct juxing float chang float kuan struct juxing shuru struct juxing r printf shu ru ju xing chang kuan n scanf f f return r void shuchu struct juxing r printf chang shi f n r chang printf kuan shi f n r kuan float mianji struct juxing r return r chang r kuan float zhouchang struct juxing r return 2 r chang 2 r kuan void main struct juxing a a shuru shuchu a printf mian ji wei f n mianji a printf zhou chang wei f n zhouchang a 3 设有学生情况登记表如表 9 3 所示 用选择法选择法对该表按成绩从小到大排序 include struct Student int num char name 8 char sex int age float score void main int i j int min struct Student temp struct Student stu 10 101 zhang M 19 98 3 102 wang F 18 87 2 103 li M 20 73 6 104 zhao F 20 34 6 105 miao M 18 99 4 106 guo M 17 68 4 107 wu F 19 56 9 108 xu F 18 45 0 109 lin M 19 76 5 110 ma F 19 85 3 for i 0 i 9 i min i for j i j 9 j if stu i score stu j 1 score min j 1 temp stu min stu min stu i stu i temp for i 0 i 9 i printf num d name s sex c age d score f n stu i num stu i name stu i s ex stu i age stu i score getchar 4 某班有 20 名学生 每名学生的数据包括学号 姓名 3 门课的成绩 从 键盘输入 20 名学生的数据 要求打印出每门课的平均成绩 以及每名学生的平 均成绩并输出最高分的学生的数据 学号 姓名 3 门课 平均成绩 include struct student char num 4 char name 8 float score 3 float ave void main struct student s1 20 int i j float avg1 0 avg2 0 avg3 0 sum 0 for i 0 i 20 i scanf s s f f f s1 i num s1 i name for i 0 i 20 i avg1 s1 i score 0 avg2 s1 i score 1 avg3 s1 i score 2 s1 i ave s1 i score 0 s1 i score 1 s1 i score 2 3 avg1 20 avg2 20 avg3 20 printf 2 men ke de ping jun cheng ji f f f n avg1 avg2 avg3 sum s1 0 ave j 0 for i 1 i 20 i if s1 j ave s1 i ave j i for i 0 i 20 i printf ping jun cheng ji f n s1 i ave printf ZuiGaoFen XueHao s XingMing s ChengJi f f f PingJun f n s1 j num s1 j name s1 j score 0 s1 j score 1 s1 j score 2 s1 j ave 5 统计候选人总得票数 假设有 5 名候选人 每次输入一个得票候选人的名 字 要求最后按从大到小输出每个人的得票数排名 include include struct note char name 20 int count void main struct note notes 5 zhao 0 qian 0 li 0 sun 0 wang 0 char tou 20 int i j for i 0 i 20 i scanf s tou for j 0 j 20 j if strcmp tou notes j name notes j count for i 0 i 4 i for j i j 4 j if notes i count notes j 1 count struct note temp notes i notes i notes j 1 notes j 1 temp for i 0 i 5 i printf XingMing s PiaoShu d n notes i name notes i count 6 定义一个结构体变量 包括年 月 日 计算该日在本年中是第几天 注意闰年问题 include struct date int year int month int day void main struct date date1 int i sum 0 scanf d d d for i 1 i2 sum 3 if date1 year 400 0 date1 year 4 0 sum date1 day printf shi di d tian n sum 第十章 一 单项选择一 单项选择 1 B 2 A 3 B 4 B 5 B 二 阅读程序写结果二 阅读程序写结果 1 答案 19 2 答案 k 2 a 4 b 3 3 答案 6 4 答案 0 1 3 6 三 程序填空三 程序填空 1 答案 1 p a 2 p a 4 或 p 2 答案 1 p s 2 p 3 答案 1 k p 2 findmax a 10 b j 0 或 a i b j 0 四 程序问答四 程序问答 1 答案 1 7 2 首地址 2 答案 1 12 9 6 2 从大到小排序 降序排列 3 结果仍是 12 9 6 但此处输出结果不是排序后的结果 输出 的是输入顺序 的数字 3 答案 1 aace 2 把字符数组中的 t 删除掉 3 atace 五 程序改错五 程序改错 1 答案 1 scanf s str 2 strcpy max str 3 strcmp max str 4 strcpy max str 2 答案 1 t s 2 p 1 p 3 p 1 t 3 答案 1 p q 2 q 0 六 编程六 编程 以下程序均要求使用指针来实现 1 编程判断输入的一串字符是否为 回文 是则输出 Yes 否则输出 No 所 谓 回文 是指正读和倒读都一样的字符串 如 ratar 就是回文 include include void main char str 100 p q int flag 1 scanf s str p str q str strlen str 1 while p q if p q flag 0 break if flag 1 printf Yes n else printf No n 2 strcat 函数用来连接两个字符串 如 char s1 20 holiday s2 10 economy 则 strcat s1 s2 可以将 s2 中的字符串连接到 s1 字符串的后面 此时 s1 中的 字符串变为 holiday economy 请自行编写函数 mystrcat 完成上述功能 include include void mystrcat char p char q while p p while q p q p 0 void main char s1 20 s2 20 char p s1 q s2 gets s1 gets s2 mystrcat p q printf s n s1 2 有 5 个候选人参与选举 共 100 张选票 每张选票上只能推选一个人 编 程统计每个候选人的得票数 并输出结果 include include void main char name 5 zhang wang li zhao liu char note 10 int j int count1 0 count2 0 count3 0 count4 0 count5 0 for j 0 j 10 j scanf s note if strcmp name 0 note count1 if strcmp name 1 note count2 if strcmp name 2 note count3 if strcmp name 3 note count4 if strcmp name 4 note count5 printf Wu Ge Ren De De Piao Fen Bie Wei n printf d d d d d count1 count2 count3 count4 count5 3 统计一段英文短文中出现的单词的个数 单词间以空格分隔 可以有多个 空格 include include void main char a 39 char p a int count 0 flag 0 gets a if p flag 1 while p 0 if p p if flag 1 printf the num of words is d n count else printf the num of words is d n count 1 4 对一组整数降序排序 要求排序功能由调用函数实现 include void main void sort int
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 子宫肌瘤教学课件
- 子宫内膜癌医学课件
- 年度安全培训表课件
- 年度培训专职安全员课件
- 年底安全生产培训会议课件
- 年后复工安全培训课件
- 工业成本核算课件
- 2024年黑河北安市事业单位招聘考试真题
- 2025年外来纵向科研项目经费资助合同书6篇
- 委托培训交通安全课件
- 2025湖南益阳安化县事业单位招聘工作人员61人考试参考试题及答案解析
- 7 呼风唤雨的世纪 课件
- 电瓶托盘堆垛车安全培训课件
- 快递分拣中心操作流程及安全规范
- 机加工安全质量培训计划课件
- 2025年全国计算机等级考试三级网络技术模拟题及答案
- 2025至2030年中国卡丁车俱乐部行业市场调研分析及投资战略咨询报告
- 建设项目环境影响评价分类管理名录(报告书、表、登记表)
- 加油站职业健康危害因素分析
- 2025年杭州市上城区九堡街道社区卫生服务中心招聘编外4人笔试备考试题及答案解析
- 2025年煤矿从业人员安全培训考试题库及答案
评论
0/150
提交评论