okay.. ive been working on it.. and i have this..
some one pleaseeeeeeeeeee help........Code:#include <iostream> #include <string> #include <map> using namespace std; class Cmp : public std::binary_function<std::string,std::string,bool> { public: bool operator()(const std::string& s1, const std::string& s2){ } }; typedef std::map<std::string, int, Cmp> MAP; typedef enum {s1, s2} STATUS; int main(void){ char c; MAP m; std::string buffer; STATUS status=s1; while(std::cin.get(c)){ switch(status){ case s1: if(isalpha(c)){ buffer=c; //m[buffer]++; status=s2; } break; case s2: if(isalnum(c)){ //m[buffer]++; buffer+=c; }else{ // std::cout << buffer << std::endl; //m[buffer]++; status=s1; } break; } } if(status=s2){ // std::cout << buffer << std::endl; //m[buffer]++; } /*MAP::iterator i = m.begin(); while ( i != m.end() ) { cout << i->first << ':' << i->second << endl; ++i; */ for(MAP::iterator i=m.begin(); i!=m.end(); ++i){ std::cout << i->first << ":" << i->second << std::endl; } return 0; }




Reply With Quote