Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
0MS 利用二维数组的一点小转换 很简洁 附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator