hash_dic.c
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 0k
Development Platform:

MultiPlatform

  1. #include <LEDA/hash.h>
  2. int Hash(const string& x) { return (x.length() > 0) ? x[0] : 0; }
  3. int hash_last(const string& x) 
  4. { int l = x.length();
  5.   return (l > 0) ? x[l-1] : 0; }
  6. main()
  7. {
  8.   hash<string,int> D;
  9.   hash<string,int> D1(hash_last);
  10.   hash_item it;
  11.   string s;
  12.   while (cin >> s)
  13.   { it = D.lookup(s);
  14.     if (it==nil) D.insert(s,1);
  15.     else D.change_inf(it,D.inf(it)+1);
  16.   }
  17.   forall_items(it,D) cout <<  D.inf(it) << " " << D.key(it) << "n";
  18.   return 0;
  19. }