博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU1200 POJ2039 ZOJ2208 UVALive3084 To and Fro【密码】
阅读量:6494 次
发布时间:2019-06-24

本文共 2198 字,大约阅读时间需要 7 分钟。

Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 9285   Accepted: 6261

Description

Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular array of letters. For example, if the message is "There’s no place like home on a snowy night" and there are five columns, Mo would write down  
t o i o yh p k n ne l e a ir a h s ge c o n hs e m o tn l e w x
Note that Mo includes only letters and writes them all in lower case. In this example, Mo used the character "x" to pad the message out to make a rectangle, although he could have used any letter.  
Mo then sends the message to Larry by writing the letters in each row, alternating left-to-right and right-to-left. So, the above would be encrypted as  
toioynnkpheleaigshareconhtomesnlewx  
Your job is to recover for Larry the original message (along with any extra padding letters) from the encrypted one.  

Input

There will be multiple input sets. Input for each set will consist of two lines. The first line will contain an integer in the range 2. . . 20 indicating the number of columns used. The next line is a string of up to 200 lower case letters. The last input set is followed by a line containing a single 0, indicating end of input.

Output

Each input set should generate one line of output, giving the original plaintext message, with no spaces.

Sample Input

5toioynnkpheleaigshareconhtomesnlewx3ttyohhieneesiaabss0

Sample Output

theresnoplacelikehomeonasnowynightxthisistheeasyoneab

Source

Regionals 2004 >> North America - East Central NA

问题链接:。

问题简述:(略)

问题分析

虽然字符串是放在一维数组里,也可以按二维数组的形式对其进行访问,是一个下标映射的问题。

此外,还需要考虑行的奇偶和行中的顺序访问(奇数行顺序访问)与逆序访问(偶数行逆序访问)。

程序说明:(略)

AC的C语言程序(代码中有C++的注释,需要用C++编译)如下:

/* HDU1200 POJ2039 ZOJ2208 UVALive3084 To and Fro */#include 
#include
int main(void){ int c, r, oddeven, len, i, j; char s[200+1]; while(scanf("%d", &c) != EOF) { if(c == 0) break; scanf("%s", s); len = strlen(s); r = len / c; for(j=0; j

转载于:https://www.cnblogs.com/tigerisland/p/7564603.html

你可能感兴趣的文章
DICOM医学图像处理:DICOM网络传输
查看>>
nio和传统Io的区别
查看>>
移动端网页布局中需要注意事项以及解决方法总结
查看>>
(原创)Linux下查看系统版本号信息的方法
查看>>
oracle
查看>>
redis使用过程中主机内核层面的一些优化
查看>>
我也要谈谈大型网站架构之系列(2)——纵观历史演变(下)
查看>>
OctoberCMS目录结构-基于Laravel
查看>>
大话设计模式(Golang) 二、策略模式
查看>>
JQuery页面随滚动条动态加载效果实现
查看>>
Jackson 处理is开头的字段
查看>>
使用PostgreSQL 9.6 架设mediawiki服务器
查看>>
数据库服务器硬件对性能的影响
查看>>
LVM
查看>>
windows+群辉服务器环境下,搭建git版本管理
查看>>
Boolean类型
查看>>
Ubuntu 修改源
查看>>
php 几个比较实用的函数
查看>>
(译)OpenGL ES2.0 – Iphone开发指引
查看>>
@RestController 与 @RequestMapping
查看>>