首页 > 其他 > 详细

POJ 2039 To and Fro(水题)

时间:2014-09-02 21:25:55      阅读:254      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!