// usage: anagram word // So far just works on single word s, i.e. it doesn't take phrases as // input and can't rearrange a single word into several smaller words. //#include #include #include #include #include #include using namespace std; int main(int argc,char *argv[]) { if (argc==1) { cout << "usage: anagram word " << endl; system("pause"); return 0; } char name[100]; char newname[100]; strcpy(name,argv[1]); strcpy(newname,argv[1]); int length=strlen(name); // read in dictinary and move to vector v ifstream in("BigWordList.txt"); if(in==NULL) cout << "BigWordList.txt needs to be in same folder as anagram.exe" << endl; vector v; istream_iterator input(in); istream_iterator end; back_insert_iterator > dest (v); copy(input, end, dest); vector::iterator v_iter1(v.begin()); vector::iterator v_iter2(v.end()); // calculate all permutations vector A; for (int i=0;i::iterator iter1(A.begin()); vector::iterator iter2(A.end()); vector w; // get w set up with 1,2,... length for (int i=0;i