码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 2039 To and Fro(水题)

时间:2014-09-02 21:25:55      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:水题

【题目简述】:字符串的简单处理,看懂题意,特别是他给的那个例子就好,很简单


见代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

char str[211][211];

int main()
{
	int colum;
	char str1[211];
	int tmp;
	while(cin>>colum,colum)
	{
		cin>>str1;
		int len = strlen(str1);
		tmp = len/colum;
		int count = 0;
		for(int i = 0;i<tmp;i++)
		{
			if(i%2 == 0)
			for(int j = 0;j<colum;j++)
				str[i][j] = str1[count++];
			else
			for(int j = colum-1;j>=0;j--)
				str[i][j] = str1[count++];
		}
		for(int i = 0;i<colum;i++)
		{
			for(int j = 0;j<tmp;j++)
				cout<<str[j][i];
		}
		cout<<endl;
	}
	return 0;
}


POJ 2039 To and Fro(水题)

标签:水题

原文地址:http://blog.csdn.net/u013749862/article/details/39011423

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!