Introduction

This is my blog of programming, I take notes and leave codes of computer science problems I solved here. Be my guest to comment :)

Friday, March 8, 2013

uva 10098 - Generating Fast

 1  /*
 2  Problem link
 3  Type: Adhoc
 4  Algorithm:
 5  */
 6  #include <iostream>
 7  #include <cstring>
 8  #include <cmath>
 9  #include <cstdlib>
10  #include <string>
11  #include <cstdio>
12  #include <vector>
13  #include <algorithm>
14  
15  using namespace std;
16  
17  vector<char> a;
18  
19  int main()
20  {
21      int nTest;
22      string line;
23      cin >> nTest;
24      getline(cin,line);
25      while (nTest--)
26      {
27          getline(cin,line);
28          a.clear();
29          for (unsigned int i=0; i<line.length(); i++) a.push_back(line[i]);
30          sort(a.begin(),a.end());
31          do
32          {
33              for (unsigned int i=0; i<a.size(); i++) cout << a[i];
34              cout << endl;
35          } while(next_permutation(a.begin(),a.end()));
36          cout << endl;
37      }
38      return 0;
39  }

No comments:

Post a Comment