Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- string* kopiuj( char abc[])
- {
- string* wsk;
- wsk = new string;
- for(int i=0;i<5;i++) wsk->push_back(abc[i]);
- delete wsk;
- return wsk;
- }
- char* kopiuj2(string &def)
- {
- char* wsk;
- wsk = new char[def.size()];
- for(int i =0;i< def.size()+1;i++){
- wsk[i]=def[i];
- }
- delete wsk;
- return wsk;
- }
- vector<int>* kopiuj3(int tab[])
- {
- vector<int>* wsk;
- wsk = new vector<int>;
- for(int i=0;i<10;i++){
- wsk->push_back(tab[i]);
- }
- delete wsk;
- return wsk;
- }
- int* kopiuj4 (vector<int> &dupa){
- int* wsk = new int[10];
- for(int i=0;i<10;i++){
- wsk[i]=dupa[i];
- }
- delete wsk;
- return wsk;
- }
- int main()
- { //zad 21
- char abc[5] = {'a','b','c','d'};
- cout<<kopiuj(abc)<<endl;
- //zad 22
- string def = "podstawy";
- cout<<kopiuj2(def)<<endl;
- //zad 23
- int tab[] = {1,2,3,4,5,6,7,8,9,0};
- cout<<kopiuj3(tab)<<endl;
- //zad 24
- vector<int> dupa = {1,2,3,4,5,6,7,8,9,0};
- cout<<kopiuj4(dupa)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement