算法分析及设计-大型实验报告样本

上传人:第*** 文档编号:61384909 上传时间:2018-11-30 格式:PDF 页数:12 大小:330.32KB
返回 下载 相关 举报
算法分析及设计-大型实验报告样本_第1页
第1页 / 共12页
算法分析及设计-大型实验报告样本_第2页
第2页 / 共12页
算法分析及设计-大型实验报告样本_第3页
第3页 / 共12页
算法分析及设计-大型实验报告样本_第4页
第4页 / 共12页
算法分析及设计-大型实验报告样本_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《算法分析及设计-大型实验报告样本》由会员分享,可在线阅读,更多相关《算法分析及设计-大型实验报告样本(12页珍藏版)》请在金锄头文库上搜索。

1、算法分析大型实验报告 编号编号标题标题算法算法 题目一题目一1005Jugs模拟模拟 题目二题目二1007Do the Untwist字符串字符串 班班级级: 姓姓名名: 学学号号: 指导老师指导老师: 20112011 年年 8 8 月月 ZJUT-1005 Jugs1 Special Judge Time limit: 1 SecondsMemory limit: 32768K In the movie “Die Hard 3“, Bruce Willis and Samuel L. Jackson were confronted with the following puzzle. Th

2、ey were given a 3-gallon jug and a 5-gallon jug and were asked to fill the 5-gallon jug with exactly 4 gallons. This problem generalizes that puzzle. You have two jugs, A and B, and an infinite supply of water. There are three types of actions that you can use: (1) you can fill a jug, (2) you can em

3、pty a jug, and (3) you can pour from one jug to the other. Pouring from one jug to the other stops when the first jug is empty or the second jug is full, whichever comes first. For example, if A has 5 gallons and B has 6 gallons and a capacity of 8, then pouring from A to B leaves B full and 3 gallo

4、ns in A. A problem is given by a triple (Ca,Cb,N), where Ca and Cb are the capacities of the jugs A and B, respectively, and N is the goal. A solution is a sequence of steps that leaves exactly N gallons in jug B. The possible steps are fill A fill B empty A empty B pour A B pour B A success where “

5、pour A B“ means “pour the contents of jug A into jug B“, and “success“ means that the goal has been accomplished. You may assume that the input you are given does have a solution. Input Input to your program consists of a series of input lines each defining one puzzle. Input for each puzzle is a sin

6、gle line of three positive integers: Ca, Cb, and N. Ca and Cb are the capacities of jugs A and B, and N is the goal. You can assume 0 using namespace std; int main() int ca,cb,n; while (cincacbn) int bnow; int b = 0; while (b != n) /只要 b 水壶不溢出,就让 a 水壶灌个够 for (int i=0; i #include using namespace std;

7、 int main() int k;/key char a80;/原始密文 char c80;/解密后的明文 int b100;/ciphercode while(cink int n = strlen(a); /根据原始密文,计算 ciphercode for(int i=0; i=a struct Fat int bean;/存放该库房中 JavaBean int food;/存放换取该库房中的 JavaBean 所需要的猫食代价 double good;/用猫食换取 JavaBean 时的性价比 ; int main() /ifstream cin(“ch05-04.in“); int

8、m, n; Fat iMouse1001; while(cinmn i iMousei.beaniMousei.food; iMousei.good = double (iMousei.bean) / iMousei.food; /按性价比进行降序排序(冒泡排序) for(int i = 0; i = iMousei.food) sum += iMousei.bean; m -= iMousei.food; else /所剩猫食不多换取一个库房的 JavaBean,按比例换取 JavaBean sum += iMousei.bean * double(m) / iMousei.food; break; cout.precision(3); coutfixedsumendl; return 0; 附录:设计说明书格式附录:设计说明书格式(请删除请删除) 全部为 5 号字,单倍行距! 中文:宋体; 英文:Times New Roman; 首行缩进:2 字符

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号