set.c
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
开发平台:

MultiPlatform

  1. #include <LEDA/set.h>
  2. //void print(set<string> S, string s)
  3. void print(const set<string>& S, string s)
  4. { cout << s;
  5.   forall(s,S) cout << s << " ";
  6.   newline;
  7.  } 
  8. main()
  9. {
  10. set<string> S, S1;
  11. string s;
  12. while (cin >> s) 
  13.  { if (s == "stop") break;
  14.    S.insert(s);
  15.   }
  16. S1 = S;
  17. print(S, "S = ");
  18. print(S1,"S1 = ");
  19. while (cin >> s) 
  20.    if (S1.member(s))
  21.    { cout << "delete " << s << "n";
  22.      S1.del(s);
  23.     }
  24.    else cout << s << "  not in S1 n";
  25. print(S, "S = ");
  26. print(S1,"S1 = ");
  27.  return 0;
  28. }