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

大水题

Posted by KatrineYang at 2016-08-23 04:47:36 on Problem 1617
#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:
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