Руководство по стандартной библиотеке шаблонов STL

       

int main


#include <stl.h> #include <iostream.h>

int v1[3] = { 13, 18, 23 }; int v2[4] = { 10, 13, 17, 23 }; int result[4] = { 0, 0, 0, 0 };

int main () { set_difference (v1, v1 + 3, v2, v2 + 4, result); for (int i = 0; i < 4; i++) cout << result[i] << ' '; cout << endl; set_difference (v2, v2 + 4, v1, v1 + 2, result); for (i = 0; i < 4; i++) cout << result[i] << ' '; cout << endl; return 0; }



#include <stl.h> #include <iostream.h>

int main () { vector <int> v1 (10); iota (v1.begin (), v1.end (), 0); vector <int> v2 (10); iota (v2.begin(), v2.end (), 7); ostream_iterator <int> iter (cout, " "); cout << "v1: "; copy (v1.begin (), v1.end (), iter); cout << "\nv2: "; copy (v2.begin (), v2.end (), iter); cout << endl; set_difference (v1.begin (), v1.end (), v2.begin (), v2.end (), iter); cout << endl; return 0; }



#include <stl.h> #include <iostream.h> #include <string.h>

char* word1 = "ABCDEFGHIJKLMNO"; char* word2 = "LMNOPQRSTUVWXYZ";

int main () { ostream_iterator <char> iter (cout, " "); cout << "word1: "; copy (word1, word1 + ::strlen (word1), iter); cout << "\nword2: "; copy (word2, word2 + ::strlen (word2), iter); cout << endl; set_difference (word1, word1 + ::strlen (word1), word2, word2 + ::strlen (word2), iter, less<char>()); cout << endl; return 0; }


Содержание раздела