Edited by LogicKills, 21 October 2008 - 12:11 AM.
I uploaded wrong version :p
Permutations.cpp
Started by LogicKills, Oct 20 2008 11:45 PM
1 reply to this topic
#1
Posted 20 October 2008 - 11:45 PM
Whoops
http://logickills.org
Science - Math - Hacking - Tech
Science - Math - Hacking - Tech
|
|
|
#2
Posted 21 October 2008 - 12:16 AM
The version I meant to paste :]
/*
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 <iostream>
#include <algorithm>
#include <string>
#include <fstream>
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;
}
http://logickills.org
Science - Math - Hacking - Tech
Science - Math - Hacking - Tech


Sign In
Create Account


Back to top









