Advertisement
Josif_tepe

Untitled

Mar 27th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Student {
  6. private:
  7.     int *niza;
  8.     int br_predmeti;
  9. public:
  10.     Student() {}
  11.     Student(int *a, int n) {
  12.         niza = new int[n];
  13.         br_predmeti = n;
  14.         for(int i = 0; i < n; i++) {
  15.             niza[i] = a[i];
  16.         }
  17.     }
  18.     ~Student() {
  19.        
  20.     }
  21.     void pecati() {
  22.         for(int i = 0; i < br_predmeti; i++) {
  23.             cout << niza[i] << " ";
  24.         }
  25.         cout << endl;
  26.     }
  27. };
  28. int main()
  29. {
  30.     int n;
  31.     cin >> n;
  32.     int niza[n];
  33.     for(int i = 0; i < n; i++) {
  34.         cin >> niza[i];
  35.     }
  36.     Student s(niza, n);
  37.     s.pecati();
  38.    
  39.     int nov_n;
  40.     cin >> nov_n;
  41.     int nova_niza[nov_n];
  42.     for(int i = 0; i < nov_n; i++) {
  43.         cin >> nova_niza[i];
  44.     }
  45.     s = Student(nova_niza, nov_n);
  46.     s.pecati();
  47.  
  48.     return 0;
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement