-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy path10098.cpp
More file actions
executable file
·40 lines (31 loc) · 805 Bytes
/
10098.cpp
File metadata and controls
executable file
·40 lines (31 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Problem: Generating Fast, Sorted Permutation UVa 10098
Programmer: Md. Mahmud Ahsan
Description: Permutation, Using STL, sort(), next_permutation(), snail_sort()
Compiled: Visual C++ 7.0
Date: 10-07-05
*/
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
template <class BidirectionalIterator>
void snail_sort(BidirectionalIterator first, BidirectionalIterator last){
while (next_permutation(first, last)){
copy(first, last, ostream_iterator<char>(cout, ""));
cout << endl;
}
}
int main(){
int n, i, len;
cin >> n;
char str[15];
for (i = 0; i < n; ++i){
cin >> str;
len = strlen(str);
sort(str, str+len);
cout << str << endl;
snail_sort(str, str+len);
cout << endl;
}
return 0;
}