算法分析实验一报告.docxVIP

  • 9
  • 0
  • 约3.24千字
  • 约 7页
  • 2021-03-06 发布于天津
  • 举报
《算法设计与分析》实验报告 一、 实验内容描述和功能分析 二、 算法过程设计? 三、 程序调试及结果(附截图) 四、 源代码(附源代码)? 一、实验内容描述和功能分析. 1?彼岸 内容描述:突破蝙蝠的包围,yife nfei来到一处悬崖面前,悬崖彼岸就是前进的方向, 好在现在的yifenfei 已经学过御剑术,可御剑轻松飞过悬崖。 现在的问题是:悬崖中间飞着很多红,黄,蓝三种颜色的珠子,假设我们把悬崖看成一条长 度为n的线段,线段上的每一单位长度空间都可能飞过红,黄,蓝三种珠子,而 yifenfei 必定会在该空间上碰到一种颜色的珠子。如果在连续 3段单位空间碰到的珠子颜色都不一 样,则yifenfei 就会坠落。 比如经过长度为3的悬崖,碰到的珠子先后为 “红黄蓝”,或者 “蓝红黄” 等类似情况 就会坠落,而如果是 “红黄红” 或者“红黄黄”等情况则可以安全到达。 现在请问:yife nfei 安然抵达彼岸的方法有多少种? 输入:输入数据首先给出一个整数 C,表示测试组数。 然后是C组数据,每组包含一个正整数 n (n40)。 输出:对应每组输入数据,请输出一个整数,表示 yifenfei 安然抵达彼岸的方法数。 每组输出占一行。 例如:输入:2 输出:9 2 21 3 统计问题 内容描述:在一无限大的二维平面中,我们做如下假设: 1、 每次只能移动一格; 2、 不能向后走(假设你的目的地是“向上”,那么你可以向左走,可以向右走,也可以向 上走,但是不可以向下走); 3、 走过的格子立即塌陷无法再走第二次; 求走n步不同的方案数(2种走法只要有一步不一样,即被认为是不同的方案)。 输入:首先给出一个正整数 C,表示有C组测试数据 接下来的C行,每行包含一个整数 n (n=20),表示要走n步。 输出:请编程输出走n步的不同方案总数; 每组的输出占一行。 例如:输入:2 输出:3 7 2 Message Decowing 内容描述:The cows are thrilled because theyve just lear ned about en crypti ng messages. They think they will be able to use secret messages to plot meeti ngs with cows on other farms. Cows are n ot known for their in tellige nee. Their en cryptio n method is no thi ng like DES or BlowFish or any of those really good secret codi ng methods. No, they are using a simple substitutio n cipher. The cows have a decryptio n key and a secret message. Help them decode it. The key looks like this:yrwhsoujgcxqbativ ndfezmlpk Which means that an a in the secret message really means y; a b in the secret message really means r; a c decrypts to w; and so on. Blanks are not en crypted; they are simply kept in place. In put text is in upper or lower case, both decrypt using the same decrypti on key, keep ing the appropriate case, of course. 输入:* Line 1: 26 lower case characters represe nting the decrypti on key * Line 2: As many as 80 characters that are the message to be decoded 输出:* Line 1: A sin gle line that is the decoded message. It should have the same len gth as the sec ond line of in put. 例如:输入: eydbkmiqugjxlvtzp nwohracsf Kifq oua zarxa suar bti yaagrj fa xtfgrj 输出: J

文档评论(0)

1亿VIP精品文档

相关文档