home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / prog / basic / set.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  502 b   |  45 lines

  1. #include <LEDA/set.h>
  2.  
  3. declare(set,string)
  4.  
  5. void print(set(string) S, string s)
  6. { cout << s;
  7.   forall(s,S) cout << s << " ";
  8.   newline;
  9.   newline; 
  10.   S.clear();
  11.  } 
  12.  
  13. main()
  14. {
  15.  
  16. set(string) S, S1;
  17.  
  18.  
  19. string s;
  20.  
  21. while (cin >> s) 
  22.  { if (s == "stop") break;
  23.    S.insert(s);
  24.   }
  25.  
  26. S1 = S;
  27.  
  28. print(S, "S = ");
  29. print(S1,"S1 = ");
  30.  
  31. while (cin >> s) 
  32.    if (S1.member(s))
  33.    { cout << "delete " << s << "\n";
  34.      S1.del(s);
  35.     }
  36.    else cout << s << "  not in S1 \n";
  37.  
  38.  
  39. print(S, "S = ");
  40. print(S1,"S1 = ");
  41.  
  42.  
  43. }
  44.  
  45.