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
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes! | 北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

重载一个比较函数,stl自动判重,stl tql

Posted by csyfZhang at 2020-06-23 09:31:34 on Problem 1256
string s;
int N;
bool cmp(char c1, char c2) {
	if (c1 >= 'a'&&c1 <= 'z'&&c2 >= 'a'&&c2 <= 'z')return c1 < c2;
	if (c1 >= 'A'&&c1 <= 'Z'&&c2 >= 'A'&&c2 <= 'Z')return c1 < c2;
	if (c1 >= 'a'&&c1 <= 'z'&&c2 >= 'A'&&c2 <= 'Z') {
		return c1 - 'a' < c2 - 'A';
	}
	if (c2 >= 'a'&&c2 <= 'z'&&c1 >= 'A'&&c1 <= 'Z') {
		if (c2 - 'a' == c1 - 'A')return true;
		return c1 - 'A' < c2 - 'a';
	}
}
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		sort(s.begin(), s.end(), cmp);
		printf("%s\n", s.c_str());
		while (next_permutation(s.begin(), s.end(),cmp)) {
				printf("%s\n", s.c_str());
		}
	}
}

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