Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

0MS 利用二维数组的一点小转换 很简洁 附代码

Posted by wangmin666 at 2016-07-07 23:22:43 on Problem 2039
#include<iostream>
#include<string>
using namespace std;

int main()
{
	int c;
	while (cin >> c&&c != 0)
	{
		string str;
		char a[100][100];
		cin >> str;
		int m = 0;
		for (int i = 0; i <str.length()/c; i++)
		{
			for (int j = 0; j < c; j++)
			{
				a[i][j] = str[m];
				m++;
			}
		}
		for (int k = 0; k < c; k++)
		{
			for (int d = 0; d < str.length()/c; d++)
			{
				if (d % 2 == 0)
					cout << a[d][k];
				else
					cout << a[d][c-1 - k];
			}
		}
		cout << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator