To and Fro
Description
t o i o y
h p k n n
e l e a i
r a h s g
e c o n h
s e m o t
n 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
Output
Sample Input
5
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
Sample Output
theresnoplacelikehomeonasnowynightx
thisistheeasyoneab 【题意】看懂样例即可解
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int N=;
char str[N][N],na[N]; int main()
{
int n;
while(~scanf("%d",&n),n)
{
getchar();
gets(na);
int len=strlen(na);
int m=len/n;
int k=;
for(int i=;i<m;i++)
{
if(i%==)
{
for(int j=;j<n;j++)
{
str[i][j]=na[k];
k++;
}
}
else
{
for(int j=n-;j>=;j--)
{
str[i][j]=na[k];
k++;
}
}
}
for(int j=;j<n;j++)
{
for(int i=;i<m;i++)
{
printf("%c",str[i][j]);
} }
printf("\n");
}
return ;
}
To and Fro的更多相关文章
- hdoj 1200 To and Fro
To and Fro Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- POJ 2039 To and Fro(模拟)
To and Fro Description Mo and Larry have devised a way of encrypting messages. They first decide sec ...
- To and Fro(字符串水题)
To and Fro 点我 Problem Description Mo and Larry have devised a way of encrypting messages. They first ...
- POJ 2039 To and Fro
To and Fro Description Mo and Larry have devised a way of encrypting messages. They first decide sec ...
- ZOJ2208 To and Fro 2017-04-16 19:30 45人阅读 评论(0) 收藏
To and Fro Time Limit: 2 Seconds Memory Limit: 65536 KB Mo and Larry have devised a way of encr ...
- hdu 1200 To and Fro(简单模拟或DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1200 To and Fro Time Limit: 2000/1000 MS (Java/Others ...
- 解决Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker fro问题
项目中碰到一个问题,就是将一个map转换成json格式的时候出现错误,最后排查将延迟加载关闭后成功转换,因为数据量较大,于是重新创建了一个对象进行接收. 解决办法是在配置文件中进行配置 虽然解决了这个 ...
- hdu_hpu第八次周赛_1001 To and Fro 201310270918
To and Fro Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Su ...
- POJ 2039:To and Fro
To and Fro Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8632 Accepted: 5797 Descri ...
- sicily 1007. To and Fro 2016 11 02
// Problem#: 1007// Submission#: 4893204// The source code is licensed under Creative Commons Attrib ...
随机推荐
- SQL SERVER类型与C#类型对照
SQL SERVER类型 C#类型 精确数字 bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型数 ...
- go局部变量的存储空间是堆还是栈?
编译器会自动选择在栈上还是在堆上分配局部变量的存储空间,但可能令人惊讶的是,这个选择并不是由用var还是new声明变量的方式决定的. var global *int func f() { var x ...
- fr
8.3 credit sales(bad debt , ar) method1:direct write off method2:allowance method for bad debt allow ...
- js判断手机系统和微信
//判断手机浏览器 var ua = navigator.userAgent; var ipad = ua.match(/(iPad).*OS\s([\d_]+)/), isIphone = !ipa ...
- centos6.5 64位系统安装 tengine
1 安装pcre 下载好pcre 上传到服务器 我用的版本是pcre-8.31.tar.gz tar -zxvf pcre-8.31.tar.gz cd pcre-8.31 ./confi ...
- mongodb的监控与性能优化
一.mongodb的监控 mongodb可以通过profile来监控数据,进行优化. 查看当前是否开启profile功能用命令 db.getProfilingLevel() 返回level等级,值为 ...
- VSS Plugin配置FAQ(翻译)[转]
前言(译者) 就个人的成长历程来说,刚参加工作用的是 CVS ,前前后后有接近三年的使用体验,从今年开始使用 SVN .总的来说我更喜欢 SVN ,用起来的确很方便,例如在本地源代码文件中加一个空格然 ...
- 学习记录008-crond和visudo
1.每隔两个小时将/etc/servers文件打包备份到.tmp下(每次名字不同) [root@kaka cc.log]# tar zcvf /server/backup/ccc.log_$(date ...
- LAMP整理
LAMP第一部分 查看编译了哪些软件:是编译时自动生成的 Cat /usr/local/apache2/build/config.nice 网站根目录存放处: /usr/local/apache2/h ...
- sql server中备份数据的几种方式
当我们在写sql脚本要对数据表中的数据进行修改的时候,为了防止破坏数据,通常在开发前都会对数据表的数据进行备份,当我们sql脚本开发并测试完成后,再把数据恢复回来. 目前备份数据,我常用的方法有以下几 ...