// anagrams.cpp: Defines the entry point of the console application. /// This practice is to learn ifstream, istream_iterator, binary_search, next_permutation // istream_iterator This is an iterator, it is an iterator of the input stream.
#include "stdafx.h"
#include
Using namespace std;
INT Main (int Argc, char * argv []) {// accepts user input path, here you need to pay attention, IFSTREAM is used, ifstream is a class, file input retention // ifstream IFS (strpath.c_str )), It is an instance of IFStream // String StrPath ("c: //Hello.txt"); cout << "Please enter the file path to find:" Endl; cin >> strpath;
IFStream IFS (StrPath.c_STR ()); if (! ings.is_open ()) {cout << "You can't open the file << endl; return -1;}
// // read data from the file // cout << "is reading data from the file" << Endl; typedef istream_iterator
// // Sort // sort (Dictionary.begin (), Dictionary.end ()); Vector
// / / Enter the target word and find it, the idea is to transform the words you want to find, and then find it in Dictionary // must pay attention to the next_permutation algorithm usage // cout << "Please enter the word you want to find : "<< endl; for (string_input j (cin); j! = string_input (); j ) {string word = * J; sort (word.begin (), word.end ());
Bool bisfind = false; do {if (binary_search (dictionary.begin (), dictionary.end (), word) {cout << "<< word << endl; bisfind = true;
WHILE (Word.Begin (), word.end ())); if (! bisfind) {cout << "Sorry, did not find a corresponding word!" << Endl;}} Return 0;}