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;
	}
}

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

Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of ...
  • zzukun
  • zzukun
  • 2012年08月08日 16:37
  • 186

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

【poj2039】To and Fro

【poj2039】To and Fro Description Mo and Larry have devised a way of encrypting messages. They f...

POJ2039--To and Fro--字符串水题

Description Mo and Larry have devised a way of encrypting messages. They first decide secretly on t...
  • a305657
  • a305657
  • 2013年02月22日 20:01
  • 442

hdu-1200 To and Fro

To and Fro Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:zoj 2208 To and Fro
举报原因:
原因补充:

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