на главную | войти | регистрация | DMCA | контакты | справка | donate |      

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я


моя полка | жанры | рекомендуем | рейтинг книг | рейтинг авторов | впечатления | новое | форум | сборники | читалки | авторам | добавить



Example

int main() {

 const int N = 10;

 int a[N] = {4, 1, 1, 1, 1, 1, 0, 5, 1, 0};

 int b[N] = {4, 4, 2, 4, 2, 4, 0, 1, 5, 5};

 multiset A(a, a + N);

 multiset B(b, b + N);

 multiset C;

 cout << "Set A: ";

 copy(A.begin(), A.end(), ostream_iterator(cout, " "));

 cout << endl;

 cout << "Set B: ";

 copy(B.begin(), B.end(), ostream_iterator(cout, " "));

 cout << endl;

 cout << "Union: ";

 set_union(A.begin(), A.end(), B.begin(), B.end(), ostream_iterator(cout, " "));

 cout << endl;

 cout << "Intersection: ";

 set_intersection(A.begin(), A.end(), B.begin(), B.end(), ostream_iterator(cout, " "));

 cout << endl;

 set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(C, C.begin()));

 cout << "Set C (difference of A and B): ";

 copy(C.begin(), C.end(), ostream_iterator(cout, " "));

 cout << endl;

}


Description | Standard Template Library Programmer`s Guide | Definition