hdoj 1200 To and Fro
To and Fro
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5485 Accepted Submission(s): 3795
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.
#include<stdio.h>
#include<string.h>
int main()
{
int n,m,j,i,t,l,k;
char str[1100];
char s[100][100];
while(scanf("%d",&t)&&t!=0)
{
getchar();
gets(str);
l=strlen(str);
k=0;j=0;
for(i=0;i<l;i++)
{
if(k%2==0)
{
s[k][j]=str[i];
j++;
if(j==t)
k++;
}
else
{
s[k][j-1]=str[i];
j--;
if(j==0)
k++;
}
}
for(i=0;i<t;i++)
{
for(j=0;j<k;j++)
{
printf("%c",s[j][i]);
}
}
printf("\n");
}
return 0;
}
hdoj 1200 To and Fro的更多相关文章
- [acm]HDOJ 1200 To and Fro
题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1200 简单字符串处理,找规律 /* 11509672 2014-08-21 11:32:55 Acc ...
- 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 ...
- HDOJ/HDU 1200 To and Fro(加密解密字符串)
Problem Description Mo and Larry have devised a way of encrypting messages. They first decide secret ...
- HDU - 1200 To and Fro
题意:给定一个,其实是由一个图按蛇形输出而成的字符串,要求按从左到右,从上到下的顺序输出这个图. 分析: 1.把字符串转化成图 2.按要求输出图= = #include<cstdio> # ...
- 杭电hdoj题目分类
HDOJ 题目分类 //分类不是绝对的 //"*" 表示好题,需要多次回味 //"?"表示结论是正确的,但还停留在模块阶 段,需要理解,证明. //简单题看到就 ...
- HDOJ 题目分类
HDOJ 题目分类 /* * 一:简单题 */ 1000: 入门用:1001: 用高斯求和公式要防溢出1004:1012:1013: 对9取余好了1017:1021:1027: ...
- HDU字符串基础题(1020,1039,1062,1088,1161,1200,2017)
并不是很精简,随便改改A过了就没有再简化了. 1020. Problem Description Given a string containing only 'A' - 'Z', we could ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
随机推荐
- c#代码自动修改解决方案下任意文件
命名空间 using EnvDTE;using EnvDTE80; private DTE2 _applicationObject; public void AutoAddControl(插件 v_f ...
- 使用WebBrowser的记录
第一:新建一个类,用了获取WebBrowser元素的类 //需要引用 Interop.SHDocVw 和 Microsoft.mshtmlpublic class Element { //根据Name ...
- php 定时执行任务
之于是否控制,可以做到的,应借用第三个条件: config.php <?phpreturn 1;?> cron.phpignore_user_abort();//关掉浏览器,PHP脚本也可 ...
- web2.0最全的国外API应用集合
web2.0最全的国外API应用集合 原文地址:http://www.buguat.com/post/98.html 2.0时代,越来越多的API被大家广泛应用,如果你还不了解API是何物,请看这里的 ...
- Emmet Documentation
src:http://docs.emmet.io/cheat-sheet/ Emmet Documentation Syntax Child: > nav>ul>li <n ...
- C# net部署图片分布式存储服务器的小案例
如果web服务用户多了,访问多了,用户上传的图片,文件等内容放在一块,想必服务器是承受不住的,这个时候,我们就需要考虑分布式存储的方法了. 如图所示:一个web服务器拖2个图片服务器 如何做到用户上传 ...
- Linq语句与aspnetpager结合分页
public void DataBindList() { List<EnDeContent> listCon = null; in ...
- Java按正则提取字符串
在Java开发中,有时会遇到一些比较别扭的规则从字符串中提取子字符串,规则无疑是写正则表达式来表达了,那按照正则来提取子字符串就会用到java.util.regex包. java.util.regex ...
- [Android应用]《花界》V1.0 正式版隆重发布!
http://www.cnblogs.com/qianxudetianxia/archive/2012/04/05/2433669.html 1. 软件说明(1). 花界是一款看花软件:“看花,议花, ...
- 玩转createjs
标题党"玩转", 真的是在玩怎么转... 参考一篇很经典的博文:createjs入门 做移动版(750x1334)的时候出来不居中啊, 不是掉在下面就是滑到右面, canvas里面 ...