HDU1200:To and Fro
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.
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
thisistheeasyoneab
大水题
#include <stdio.h>
#include <string.h> int main()
{
char s[30][200],str[300];
int n,i,j,k,len;
while(~scanf("%d",&n),n)
{
scanf("%s",str);
len = strlen(str);
memset(s,'\0',sizeof(s));
k = 0;
for(i = 0;i<len/n && k<len;i++)
{
for(j = 0;j<n;j++)
{
if(i%2)
s[i][n-j-1] = str[k++];
else
s[i][j] = str[k++];
}
}
for(i = 0;i<n;i++)
{
for(j = 0;j<len/n;j++)
{
printf("%c",s[j][i]);
}
}
printf("\n");
}
return 0;
}
HDU1200:To and Fro的更多相关文章
- POJ 2039:To and Fro
To and Fro Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8632 Accepted: 5797 Descri ...
- enmo_day_09
1. 数据库 select name from v$database; : 数据库名称 select db_unique_name from v$database; : 数据库唯一名称 select ...
- 正则表达式 ——python 基础
一.引言 正则表达式是含有文本和特别字符的字符串,这些文本和特别字符描述的模式可以识别各种字符串. 正则表达式的强大之处在于特殊符号的应用,特殊符号定义了字符集合.子组匹配,模式重复次数...正是这些 ...
- ORACLE_CLASS_ENDING
[JSU]LJDragon's Oracle course notes In the first semester, junior year Oracle考前复习 试题结构分析: 1.选择题2x10, ...
- python 三元运算符、推导式、递归、匿名函数、内置函数
三目运算符 # 三目(元)运算符:就是 if...else...语法糖 # 前提:简化if...else...结构,且两个分支有且只有一条语句 # 注:三元运算符的结果不一定要与条件直接性关系 cmd ...
- Python——day14 三目运算、推导式、递归、匿名、内置函数
一.三目(元)运算符 定义:就是 if...else...语法糖前提:简化if...else...结构,且两个分支有且只有一条语句注:三元运算符的结果不一定要与条件直接性关系 cmd = input ...
- day 14 递归、匿名函数、内置函数
三目运算符 # 三目(元)运算符:就是 if...else...语法糖# 前提:简化if...else...结构,且两个分支有且只有一条语句# 注:三元运算符的结果不一定要与条件直接性关系cmd = ...
- Python学习之路——三元运算符推导式
三元运算符 # 生成器:包含yield关键字的函数就是生成器 def my_generator(): yield 1 yield 2 yield 3 g_obj = my_generator() # ...
- Day 14 三元运算符,列表推导式,内置函数
三目运算符 ```python# 三目(元)运算符:就是 if...else...语法糖# 前提:简化if...else...结构,且两个分支有且只有一条语句# 注:三元运算符的结果不一定要与条件直接 ...
随机推荐
- FPC Trace Pattern Layout Design Notices (軟板線路設計注意事項)
整理了一些軟板(FPCB/Flex Cable)製造廠關於線路設計的要求 (Design Guide)以避免應用上的品質問題. 1.Relationship between Through Hole, ...
- 蓝牙1.1、蓝牙1.2、蓝牙2.0(蓝牙2.0+EDR)区别
蓝牙1.2版本相对于1.1版本: 1.Adaptive Frequency Hopping(AFH):即所谓适应性跳频技术,主要的功能是用来减少蓝牙产品与其它无线通讯装置之间所产生的干扰问题 2.Ex ...
- 可以把一堆dll文件放到程序目录下的一个自建目录里面
窦宁波大哥哥的那篇文章的这种写法还是很有参考价值的. QString strLibPath(QDir::toNativeSeparators(QApplication::applicationDirP ...
- NOI2011 Day2
NOI2011 Day2 道路修建 题目描述:给出一棵树,求每条边的两边的端点数的差乘边权之和. solution: 题目可能描述得不太清楚,如图: 对于虚边,如果边权为10,两边的端点数之差为2,这 ...
- 适配器模式—STL中的适配器模式分析
适配器模式通常用于将一个类的接口转换为客户需要的另外一个接口,通过使用Adapter模式能够使得原本接口不兼容而不能一起工作的类可以一起工作. 这里将通过分析c++的标准模板库(STL)中的适配器来学 ...
- Jimmy Choo_百度百科
Jimmy Choo_百度百科 Jimmy Choo
- Emotional Mastery——英语学习小技巧之一
How can we control or manage our emotion ,so that we feel better and feel stronger when we're learni ...
- nginx File not found 错误分析与解决方法
使用php-fpm解析PHP,出错提示如下:"No input file specified","File not found",原因是php-fpm进程找不到 ...
- 多个target下编译的时候出错问题的解决
在工程里如果有多个target的时候,如图 那么编译的时候一定要注意Xcode右侧勾选了正确的target,否则有可能会导致一系列让你想不到的bug. ,另外,如果工程中有framework,那么一定 ...
- iOS点滴- ViewController详解
一.生命周期 当一个视图控制器被创建,并在屏幕上显示的时候. 代码的执行顺序 1. alloc 创建对象,分配空间 2.init (initW ...