/ ************************************************* **************************** * Ex13-2.cpp: Defines the entry point console application. * Run: * From a file, you read all the words in a file, then sort, and make a pair * question with the original words: * For the for_each algorithm, can the function pass multiple parameters? If you can, how to do * Error : * Because of the same item in MAP, it is lost here, so this will be lost here. **************************************************************************************************************************************************************************************************************************************************** ********************************************* * History: ** ************************************************** ************************** * 20 JUN 2006 XMC Create **************** ************************************************** ************ /
#include "stdafx.h" #include
Using namespace std;
Void PrintWord (String & Str) {cout << str << endl; return;}
void SortWord (string & str) {sort (str.begin (), str.end ()); return;}
INT main (int Argc, char * argv []) {// read the word from the file and put it in a vector, the member of Vector is Pair Map
Cout << "Sorting each word" << Endl; for_each (TmpWords.Begin (), TmpWords.end (), Sortword; for_each (tmpwords.begin (), tmpwords.end (), printword;
// After it, I have nothing to do, I have to make up the vector
Return 0;}