Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <iostream>
- #include <iomanip>
- using namespace std;
- class Base
- {
- public:
- int N;
- int* arr;
- };
- class Cl1 : public Base
- {
- public:
- void size(int n)
- {
- this->N=n;
- arr = new int[n];
- }
- };
- class Cl2 : public Base
- {
- public:
- void sort(int* arr, int n)
- {
- for (int i = 0; i < n - 1; i++) {
- for (int j = 0; j < n - i - 1; j++) {
- if (arr[j] > arr[j + 1]) swap(arr[j], arr[j + 1]);
- }
- }
- }
- void out(int*arr,int n)
- {
- for (int i = 0; i < n; i++)
- cout << setw(5)<<arr[i];
- }
- };
- class Cl3 : public Cl1, public Cl2
- {
- public:
- void input(int*arr,int n)
- {
- for (int i = 0; i < n; i++)
- cin >> arr[i];
- }
- void func(int*arr,int n)
- {
- input(arr,n);
- cout << "Array dimension: "<<n<<endl;
- cout << "The original array:";
- out(arr,n);
- sort(arr,n);
- cout << "\nAn ordered array:";
- out(arr,n);
- }
- };
- int main()
- {
- Cl3 b;
- int N;
- cin >> N;
- b.size(N);
- int* mass=new int[N];
- b.func(mass,N);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement