# 《ACM 程序设计训练 1》
# 一、任务 1
## 1.1 +B for Input-Output Practice(II)
**任务内容**
Your task is to calculate the sum of some integers.
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/e40ce8e0fb65e24cbb1efe8d5a68afc9.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/45fd98f2fa62790364f21c99b0f3c953.writebug)
## 1.2 +B for Input-Output Practice (III)
任务内容
```c++
Your task is to Calculate a + b.
```
实现代码
![](https://www.writebug.com/myres/static/uploads/2021/11/4/1f98107bdd8274f8ba186d874fd3bf4f.writebug)
运行结果分析
![](https://www.writebug.com/myres/static/uploads/2021/11/4/f80baf05d70ba9aebc9cb8589a173dae.writebug)
## 1.3 Sum Problem(II)
**任务内容**
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/317dbf768128026e5bac325e753d3078.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/af9dce79f85476e1db16ef18c732e1bc.writebug)
## 1.4 +B for Input-Output Practice(IX)
**任务内容**
Your task is to calculate the sum of some integers.
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/4c20ac3f44e7b757270c6c260e64518d.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/b482bdec48baf7177c193f1db7c4d270.writebug)
## 1.5 + B Problem Too
**任务内容**
```c++
This problem is also a A + B problem,but it has a little difference,you should determine does (a+b) could be divided with 86.For example,if (A+B)=98,you should output no for result.
```
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/6796c9aea3f735f3f49342c34f632e2f.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/25169fb1b946a770f70a633daf06e290.writebug)
# 二、任务 2
## 2.1 猴子吃桃
**任务内容**
Almost all young man know Monkey Sun whose name is Sun Wukong. One day he steals many peaches from the kingdom of heaven. First day, he ate a half of the peaches, then ate another one of the left peaches.The next day, he ate a half of the left peaches, then another one.Until the n-th day,before he ate he found only one peach. Please help Sun Wukong to calculate how many peaches he took from the kingdom of heaven.
**设计思路**
If 判断 n 是否在一到三十天之内,向 a 函数传入天数,利用递归计算出一共有 b 个桃并返回。
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/957a1aa854b18ad3605da0d6b620cb7e.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/3a1cb418b3e67c919a6a79f26b65de44.writebug)
## 2.2 百鸡问题
**任务内容**
古代《张邱建算经》中的“百鸡问题”是一道很有名的算题。题目内容是:用 100 元买 100 只鸡,大公鸡 5 元 1 只,母鸡 3 元 1 只,小鸡 1 元 3 只。问各能买多少只?
**设计思路**
先排列出公鸡母鸡的个数,再确定小鸡个数
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/65eaa515086e7d8976b794e3d6004b40.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/dc85df8c353cce62c3b36cea6d03079b.writebug)
## 2.3 深入浅出学算法 004-求多个数的最小公倍数
**任务内容**
求 n 个整数的最小公约
**设计思路**
用辗转相除法求最大公约数,利用递归调用函数 a
再求出最小公倍数
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/baec297924bd81fce2fec6ba96ccd39e.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/6b432673cd30d75a459614bd6a358f9b.writebug)
## 2.4 深入浅出学算法 007-统计求和
**任务内容**
求含有数字 a 且不能被 a 整除的 4 位整数的个数,并求这些整数的和
**设计思路**
先列举出四位数,在利用函数逐位判断数字是否含 a,并返回 1 或 0,再求这些整数和
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/6c9354a8637fd9bc28a1802b23b360d9.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/a752617411ae2b155892efab876180e6.writebug)
# 三、任务 3
## 3.1 ASCII 码排序
**任务内容**
输入三个字符后,按各字符的 ASCII 码从小到大的顺序输出这三个字符。
注:输入:输入数据有多组,每组占一行,有三个字符组成,之间无空格
输出:对于每组输入数据,输出一行,字符中间用一个空格分开
如:输入:qwe
输出:e q w
输入:asd
输出:a d s
**设计思路**
看题目时没有仔细看只需要输入三个字符,就利用数组可以输入多个字符进行冒泡排序之后输出
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/7ef6520f00468b8c6f9a8d148c024297.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/00a56d7e2292d11af297bdcd9fda7a2f.writebug)
## 3.2 计算两点间的距离
**任务内容**
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
注:
输入:输入数据有多组,每组占一行,由 4 个实数组成,分别表示 x1,y1,x2,y2,数据之间用空格隔开。
输出:对于每组输入数据,输出一行,结果保留两位小数。
如:输入:0 0 0 1
输出:1.0
输入:0 1 1 0
输出:1.41
**设计思路**
距离为根号下(x1-x2)的平方加上(y1-y3)的平方
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/49a1a2571699653a5db70b4888f7ba0b.writebug)
**运行结果分析**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/9b95dbd80e6d352c816f2d749d02532d.writebug)
## 3.3 几天?
**任务内容**
给定一个日期,输出这个日期是该年的第几天。
输入:输入数据有多组,每组占一行,数据格式为 YYYY/MM/DD 组成,具体参见 sample input ,另外,可以向你确保所有的输入数据是合法的。
输出:对于每组输入数据,输出一行,表示该日期是该年的第几天。
如:输入:1985/1/20
输出:20
输入:2006/3/12
输出:71
**设计思路**
先定义一个二维数组放入每个月的天数,先判断是否闰年,再根据月份日期,求出天数。
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/5d6baf9dc2a0ba95003b8148595eac5b.writebug)
运行结果分析
![](https://www.writebug.com/myres/static/uploads/2021/11/4/e1a74481f5502fdc93b9be25cb64cc48.writebug)
## 3.4 数 7
**任务内容**
试求含有数字 7 且不能被 7 整除的 5 位整数的个数,并求这些数字的和.同时,求这些整数中恰含 2 个数字 7 的整数的个数,并求这些数字的和.思考:若含 3,4 个 7 呢,你会做吗?
**设计思路**
先列出 i 五位数字,在调用 fun 函数进行判断
参数为所判断的数字 2. k 参数为至少含几个数七
参数为'1'时恰含 k 个数七,j 参数为'2'时至少含 k 个数七
**实现代码**
![](https://www.writebug.com/myres/static/uploads/2021/11/4/0d44feedb3840697776faa319c87276e.writebug)
运行结果分析
![](https://www.writebug.com/myres/static/uploads/2021/11/4/984dc11347e15ab0f97d04806686d082.writebug)
## 3.5 偶数求和
**任务内容**
有一个长度为 n(n<=100)的数列,该数列定义为从 2 开始的递增有序偶数,现在要求你按照顺序每 m 个数求出一个平均值,如果最后不足 m 个,则以实际数量求平均值。编程输出该平均值序列。
输入:输入数据有多组,每组占一行,包含两个正整数 n 和 m,n 和 m 的含义如上所述
输出:对于每组输入数据,输出一个平均值�
没有合适的资源?快使用搜索试试~ 我知道了~
基于C语言进行ACM 程序设计训练
共50个文件
png:30个
c:17个
license:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 91 浏览量
2023-07-26
11:03:52
上传
评论
收藏 1.17MB ZIP 举报
温馨提示
任务一: 1 +B for Input-Output Practice(II);2 +B for Input-Output Practice (III);3 Sum Problem(II);4 +B for Input-Output Practice(IX);5 + B Problem Too; 任务 二:1 猴子吃桃;2 百鸡问题;3 求多个数的最小公倍数; 4 统计求和; 任务 三:1 ASCII 码排序;2 计算两点间的距离;3 几天?4 数 7;5 偶数求和;6 手机短号;
资源推荐
资源详情
资源评论
收起资源包目录
基于C语言进行ACM 程序设计训练.zip (50个子文件)
acm_c
LICENSE 1KB
ACM程序设计训练1 课程设计报告-施凯斌.doc 677KB
具体代码
1-1-D-多组数之和.c 295B
1-2-D-统计求和.c 414B
附6-手机短号.c 362B
1-1-C-1到n的和.c 241B
附4-数7.c 675B
1-2-B-百鸡问题.c 133B
1-2-A-猴子吃桃.c 230B
1-2-C蔡大佬.c 415B
1-1-E-和的判断.c 168B
附2-两点间距离.c 230B
1-2-C-多个数的最小公倍数.c 312B
附1-字符排序.c 430B
1-1-F蔡大佬.c 271B
附5-偶数求和.c 444B
1-1-A-一些数的和.c 223B
附3-第几天.c 393B
1-1-B-a+b的和.c 142B
img.doc-md
27-af0a41c1cf148d834c6703cc687669a2.png 40KB
13-3ad981607c49daf8fdd43fb0b758c56e.png 18KB
4-24e371a159095d92f3448fe212452c24.png 4KB
5-691fc63de6641c9d7460561886a545d6.png 17KB
10-b39de06b421cc9e9a6c4dbc51142b170.png 1KB
3-70ebbcd16b786a4bac5146eaba1869fc.png 16KB
6-2926e281d0fc8fe9e550d2aa9ffa0530.png 862B
22-9232a90b2854fa550c4fa436480962f1.png 3KB
15-7f6113de2faa11c97bcaf40da810b60a.png 24KB
21-6529f84b6e5bad1d083edb50085626cd.png 47KB
9-eca4b20d20af8fbcf3c2343667e829b2.png 18KB
26-345698b318e3aed370f2e1b647c70194.png 5KB
24-4d301a953a5b1cd5eb64adf6d9c9df1f.png 4KB
19-b6ea07d7c26527ac52c991308c3f9538.png 82KB
7-f512806c6ce1bcbf3794640c0d61aa6e.png 24KB
30-d0b72c8be59862cd001d081554d91808.png 5KB
11-e2112d19398f404fe014ed558d49df43.png 20KB
8-dcc5d8249f73360412b234ac09099035.png 3KB
14-3b95047bbd0835a481b00d029c2293bb.png 5KB
18-946730e7afb16a7b0240de932b6aa972.png 4KB
23-6a362377aa020b783dd0c774415dc2d8.png 80KB
2-bbfdb6d9ed371b20e625d1b18afea795.png 2KB
1-951ada85eae091fe8ea59f25139e9a9c.png 20KB
16-032f978216a90930e03bdeb364e4f1d3.png 4KB
12-588bb05f88d481200759f1b28173ee52.png 584B
25-78f24a0ece338858ebeafe76e28858a6.png 48KB
29-2f2b46a70040211127ee9df41729ab0b.png 70KB
28-e9f950391e84438a96669853ccb0e460.png 3KB
17-2379233309d67fd08551ad3e648a0bca.png 29KB
20-f5c1c495fd00dcfd795776f5487a3c35.png 3KB
README.md 11KB
共 50 条
- 1
资源评论
神仙别闹
- 粉丝: 2668
- 资源: 7640
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功