/* Coded by: LogicKills; For: logickills.org; Reason: Somene asked for help; Notes: All it does it write to permutations.txt Doesn't check for existance, or error. Overwrites permutations from older execution. Made this in about 5 min :] */ #include #include #include #include using std::string; using std::cout; using std::endl; using std::cin; using std::ofstream; int main(int argc, char *argv[]) { if (argc != 2) { cout << "\nUsage: prm [ word ] " << endl; cout << " \nNote: " << endl; cout << " permutations.txt will be saved in the same dir that the prm.exe is in." << endl; return 1; } string x = argv[1]; int z = 1; ofstream outFile; outFile.open("permutations.txt"); outFile << "Permutations of the word " << x << endl; sort(x.begin(),x.end()); outFile << x << std::endl; while(next_permutation(x.begin(), x.end())) { outFile << x << endl; z++; } outFile << "Total number of permutations: " << z << endl; return 0; }