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 ...
随机推荐
- 计算字符串和文件的MD5值
//计算字符串的MD5值 public string GetMD5(string sDataIn) { MD5CryptoServiceProvider md5 = new MD5CryptoServ ...
- POJ 1442 Black Box 堆
题目: http://poj.org/problem?id=1442 开始用二叉排序树写的,TLE了,改成优先队列,过了.. 两个版本都贴一下吧,赚稿费.. #include <stdio.h& ...
- OC中格式化输出符号
定义 说明 %@ Objective-C object, printed as the string returned by descriptionWithLocale: if available, ...
- Error Code: 1064 – You have an error in your SQL syntax解决几个方法
本文转自 http://www.anyiwa.com/?p=1066 Error Code: 1064 – You have an error in your SQL syntax解决几个方法 十一月 ...
- Android之TextView组件学习
一.基础学习 1.findViewById返回View类,该类是所有View组件的父类. 2.子类比父类拥有更多的属性和方法,不过子类找不到的话去父类找 3.marquee:华盖,跑马灯效果:orie ...
- sharepoint 2013 安装配置PowerView
安装sharepoint 2013 网络上有很多说明.这里列出两个实例: 1.说得比较详细,并提供了下载连接:http://www.sqlant.com/2012/10/sharepoint-2013 ...
- Java ,单实例 多线程 ,web容器,servlet与struts1-2.x系列,线程安全的解决
1.Servlet是如何处理多个请求同时访问呢? 回答:servlet是默认采用单实例,多线程的方式进行.只要webapp被发布到web容器中的时候,servlet只会在发布的时候实例化一次,serv ...
- [wikioi]石子归并
http://wikioi.com/problem/1048/ 区间型动态规划.参考PPT:http://wenku.baidu.com/view/73c1ded5b9f3f90f76c61bc4.h ...
- SPRING IN ACTION 第4版笔记-第一章-002-DI介绍
一. 1.knight.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=&qu ...
- C++静态变量对象的建立和删除,兼论MFC开始运行的起点(全局对象)
看了不少C++书,当讲到静态变量的时候,总是以int成员来举例,是啊,这样很好理解.但是如果这个静态变量是一个对象行不行呢?不仅行,有时候还非常必要,而且别有洞天. 比如: // .h 文件 clas ...