zoj 2208 To and Fro

原创 2012年03月31日 12:38:59
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

string str[25];

int main()
{
	int num, i, j, len;
	string input, ans;
	while (cin >> num && num)
	{
		cin >> input;
		len = input.length();
		ans.clear();
		for (i = 0; i < len / num; i++)
			str[i].clear();
		for ( i = 0, j = 0; i < len; i++)
		{
			if (i % num == 0 && i != 0)
				j = j + 1;
			str[j] += input[i];
		}
		for (i = 0; i < len / num; i++)
		{
			if (i % 2 != 0)
				reverse(str[i].begin(), str[i].end());
		}
		for (i = 0; i < num; i++)
			for (j = 0; j < len / num; j++)
			{
				ans += str[j][i];
			}
		cout << ans << endl;
	}
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

ZOJ 2208 To and Fro

题意:给一个字符串,一定方式加密,然后再解开。具体+思路如图: 收获:1.不写#include没有错误提示~            2.n不仅不能=0,也不能等于EOF,虽然我最后还是用了写一个无意...

zoj1292大整数加法

做过加法了,再做还是那套代码,不如来看看媛姐的代码,不过,好像比我的长些,我要继续努力啦,嘿嘿! #include #include #include char s1[102...

zoj2208 To and Fro水题

其实,你可以想象一下,一次就AC是多么难忘的一件事啊 这个题把读入的数据s型存到数组中,然后以列为主序输出即可 #include #include int main() { int...

zoj2208--------------------To and Fro

Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of ...

POJ 2039:To and Fro

To and Fro Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8632   Acc...

hdu 1200 To and Fro

To and Fro Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot...

HDOJ/HDU 1200 To and Fro(加密解密字符串)

Problem Description Mo and Larry have devised a way of encrypting messages. They first decide secre...

sicily 1007 To and Fro (基础题)

链接:http://soj.me/show_problem.php?pid=1007 Description Mo and Larry have devised a way of en...

HDU-1200-To and Fro(Java农夫山泉+简单模拟)

To and Fro Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tot...

To and Fro(1200)

To and Fro
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)