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 ...
随机推荐
- hdu----(5055)Bob and math problem(贪心)
Bob and math problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Java List的深度克隆
关于java List的深度克隆 List是java容器中最常用的顺序存储数据结构之一.有些时候我们将一组数据取出放到一个List对象中,但是可能会很多处程序要读取他或者是修改他.尤其是并发处理的话, ...
- JButton按钮
1.方法 void setSize(width,height):设置按钮大小 void setBounds(x,y,width,heigth):设置按钮的左上角顶点位置和大小 void setC ...
- 快速将excel数据保存到Oracle数据库中【转】
我们在工作中,也许会碰到以下情况,客户或者同事发来需要调查的数据,并不是dmp文件,而是excel文件,此时通常是一张表,少量几条记录.最近我恰好碰到了这种情况,所以做了些调查,不敢藏私,拿出来跟大家 ...
- ASP.NET的运行原理与运行机制
在Asp.net4和4.5中,新增了WebPages Framework,编写页面代码使用了新的Razor语法,代码更加的简洁和符合Web标准,编写方式更接近于PHP和以前的Asp,和使用WebFor ...
- Ibatis.Net 数据库操作(四)
一.查询select 还记得第一篇示例中的是如何读出数据库里的3条数据吗? 就是调用了一个QueryForList方法,从方法名就知道,查询返回列表. 1.QueryForList 返回List< ...
- 3.5缺少动态连接库.so--cannot open shared object file: No such file or directory
总结下来主要有3种方法:1. 用ln将需要的so文件链接到/usr/lib或者/lib这两个默认的目录下边 ln -s /where/you/install/lib/*.so /usr/lib sud ...
- Ubuntu14.10+cuda7.0+caffe配置
转自:http://blog.csdn.net/lu597203933/article/details/46742199 Ubuntu14.10+cuda7.0+caffe配置 一:linux安装 L ...
- SQL学习心得(转)
http://www.cnblogs.com/lyhabc/p/3732942.html
- php可变变量
例子: <?php $a = "b"; $$a = "c"; echo $$a; echo "<br>"; echo $b ...