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 |
大水题#include <iostream> #include <string> using namespace std; int main() { while(1){ string kw, ct; cin >> kw; if(kw == "THEEND") return 0; cin >> ct; int klen = kw.length(); int len = ct.length() / klen; int order[15]; for(int i = 0; i < klen; i++){ order[i] = i; } for(int i = 1; i < klen; i++){ for(int j = i; j > 0; j--){ if(kw[order[j]] > kw[order[j-1]] || (kw[order[j]] == kw[order[j-1]] && order[j] > order[j-1])) break; int temp = order[j]; order[j] = order[j-1]; order[j-1] = temp; } } int niOrder[15]; for(int i = 0; i < klen; i++){ niOrder[order[i]] = i; } for(int i = 0; i < len; i++){ for(int j = 0; j < klen; j++){ cout << ct[niOrder[j]*len+i]; } } 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