Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- class mas {
- public:
- int * data;
- int size;
- mas(int msize, int lower, int upper) {
- data = new int[size];
- this->size = size;
- for (int i = 0; i < size; i++) {
- data[i] = (rand() % (upper - lower + 1)) + lower;
- }
- }
- ~mas() {
- delete[] data;
- }
- void out() {
- for (int i = 0; i < size; i++) {
- cout << data[i] << " ";
- }
- cout << endl;
- }
- void do_it() {
- for (int i = 1; i < size - 1; i++) {
- if (data[i] % 2 == 0) {
- data[i] += data[0];
- }
- }
- }
- void sort() {
- for (int i = 0; i < this->size - 1; i++) {
- for (int j = i + 1; j < this->size; j++) {
- if (this->data[i] > this->data[j]) {
- int temp = this->data[i];
- this->data[i] = this->data[j];
- this->data[j] = temp;
- }
- }
- }
- }
- };
- int main()
- {
- srand(time(0));
- mas array(10, -100, 100);
- array.out();
- array.do_it();
- array.out();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement