Advertisement
Guest User

Untitled

a guest
May 27th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. // Dopisz konieczne naglowki oraz dyrektywe uzycia przestrzeni nazw JEST
  2. // W programie utworzono i zainicjalizowane tablice o nazwie tab. JEST
  3. // Prosze: utworzyc wektor o takim samym typie elementow jak tablica. JEST
  4. // Napisac klase lub strukture, ktora bedzie obiektem funkcyjnym
  5. // przyjmujacym jeden argument unsigned i zwracajacym jego podwojona wartosc.
  6. // Za pomoca algorytmu transform przebiec przez cala tablice tab,
  7. // uzywajac obiektu funkcyjnego wlozyc do wektora podwojone wartosci.
  8. // Nastepnie za pomoca algorytmu copy oraz iteratora strumienia
  9. // wyjsciowego output_iterator, wypisac zawartosc wektora na ekran.
  10.  
  11. #include <iostream>
  12. #include <fstream>
  13. #include <functional>
  14. #include <algorithm>
  15. #include <list>
  16. #include <vector>
  17. #include <map>
  18. #include <iterator>
  19. #include <string>
  20. #include <cstring>
  21.  
  22. using namespace std;
  23.  
  24.  
  25. class Object
  26. {
  27. public:
  28. unsigned int ret(unsigned int arg)
  29. {
  30. return arg * 2;
  31. }
  32.  
  33. };
  34.  
  35. int main() {
  36.  
  37. array<unsigned int, 9> tab = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  38. vector<unsigned int> tab1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  39.  
  40. Object o;
  41.  
  42. transform(tab.begin().tab.end(), tab1.begin(), o.ret );
  43. ostream_iterator<unsigned int> out(cout, ", ");
  44. copy(tab1.begin(), tab1.end(), out);
  45. return 0;
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement