Вход/Регистрация
РУКОВОДСТВО ПО СТАНДАРТНОЙ БИБЛИОТЕКЕ ШАБЛОНОВ (STL)
вернуться

Менг Ли

Шрифт:

 cout ‹‹ endl;

 copy(rslt.begin, rslt.end, iter);

 cout ‹‹ endl;

 return 0;

}

rotate1.cpp

#include ‹stl.h›

#include ‹iostream.h›

int main {

 vector‹int› v1(10);

 iota(v1.begin, v1.end, 0);

 ostream_iterator‹int› iter(cout, " ");

 copy(v1.begin, v1.end, iter);

 cout ‹‹ endl;

 for (int i = 0; i ‹ v1.size; i++) {

rotate(v1.begin, v1.begin + i, v1.end);

 ostream_iterator ‹int› iter(cout, " ");

 copy(v1.begin, v1.end, iter);

 cout ‹‹ endl;

}

cout ‹‹ endl;

return 0;

}

setunon1.cpp

#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_union(v1.begin, v1.end, v2.begin, v2.end, iter);

 cout ‹‹ endl;

 return 0;

}

insert1.cpp

#include ‹iostream.h›

#include ‹stl.h›

char* array1[] = {"laurie", "jennifer", "leisa"};

char* array2[] = {"amanda", "saskia", "carrie"};

int main {

 deque‹char*› names(array1, array1 + 3);

 deque‹char*›::iterator i = names.begin + 2;

 copy(array2, array2 + 3, insert_iterator‹deque ‹char*› ›(names, i));

 deque‹char*›::iterator j;

 for (j = names.begin; j!= names.end; j++) cout ‹‹ *j ‹‹ endl;

 return 0;

}

ucompos2.cpp

#include ‹iostream.h›

#include ‹math.h›

#include ‹stl.h›

struct square_root: public unary_function‹double, double› {

 square_root {}

 double operator (double x_) const {return sqrt(x_);}

};

int input[3] = {-1, -4, -16};

int main {

 int output[3];

 transform(input, input + 3, output, compose1(square_root, negate‹int›));

 for (int i = 0; i ‹ 3; i++) cout ‹‹ output[i] ‹‹ endl;

 return 0;

}

parsrt1.cpp

#include ‹stl.h›

#include ‹stdlib.h›

#include ‹iostream.h›

int main {

 vector‹int› v1(10);

 for (int i = 0; i ‹ v1.size; i++)

 v1[i] = rand % 10;

 ostream_iterator‹int› iter(cout, " ");

 copy(v1.begin, v1.end, iter);

 cout ‹‹ endl;

 partial_sort(v1.begin, v1.begin + v1.size / 2, v1.end);

 copy(v1.begin, v1.end, iter);

 cout ‹‹ endl;

 return 0;

}

equal2.cpp

#include ‹stl.h›

#include ‹iostream.h›

bool values_squared(int a_, int b_) {

  • Читать дальше
  • 1
  • ...
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • ...

Ебукер (ebooker) – онлайн-библиотека на русском языке. Книги доступны онлайн, без утомительной регистрации. Огромный выбор и удобный дизайн, позволяющий читать без проблем. Добавляйте сайт в закладки! Все произведения загружаются пользователями: если считаете, что ваши авторские права нарушены – используйте форму обратной связи.

Полезные ссылки

  • Моя полка

Контакты

  • chitat.ebooker@gmail.com

Подпишитесь на рассылку: