Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. string* kopiuj( char abc[])
  7. {
  8.  
  9. string* wsk;
  10. wsk = new string;
  11. for(int i=0;i<5;i++) wsk->push_back(abc[i]);
  12. delete wsk;
  13. return wsk;
  14. }
  15.  
  16. char* kopiuj2(string &def)
  17. {
  18. char* wsk;
  19. wsk = new char[def.size()];
  20. for(int i =0;i< def.size()+1;i++){
  21. wsk[i]=def[i];
  22. }
  23. delete wsk;
  24. return wsk;
  25. }
  26.  
  27. vector<int>* kopiuj3(int tab[])
  28. {
  29. vector<int>* wsk;
  30. wsk = new vector<int>;
  31. for(int i=0;i<10;i++){
  32. wsk->push_back(tab[i]);
  33. }
  34. delete wsk;
  35. return wsk;
  36. }
  37.  
  38. int* kopiuj4 (vector<int> &dupa){
  39. int* wsk = new int[10];
  40. for(int i=0;i<10;i++){
  41. wsk[i]=dupa[i];
  42. }
  43. delete wsk;
  44. return wsk;
  45. }
  46.  
  47. int main()
  48. { //zad 21
  49. char abc[5] = {'a','b','c','d'};
  50. cout<<kopiuj(abc)<<endl;
  51.  
  52. //zad 22
  53. string def = "podstawy";
  54. cout<<kopiuj2(def)<<endl;
  55. //zad 23
  56. int tab[] = {1,2,3,4,5,6,7,8,9,0};
  57. cout<<kopiuj3(tab)<<endl;
  58. //zad 24
  59. vector<int> dupa = {1,2,3,4,5,6,7,8,9,0};
  60. cout<<kopiuj4(dupa)<<endl;
  61. return 0;
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement