Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Vérifier si un ‘set’ est un sous-ensemble d’un autre

 set
{filelink=15235}

#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
 
int main() {
  set<int> my_set, my_set2;
 
  for(int x=1; x<9; x++)
	  my_set.insert(x);
 
  for(x=1; x<3; x++)
	  my_set2.insert(x);
 
  if (includes(my_set.begin(), my_set.end(),my_set2.begin(), my_set2.end())) {
    cout << "my_set2 est un sous ensemble de my_setn";
  }
  if (includes(my_set2.begin(), my_set2.end(), my_set.begin(), my_set.end())) {
    cout << "my_set est un sous ensemble de my_set2n";
  }
 
  return (0);
}

No comments yet.

Leave a Comment