Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- class chlen { // объявление класса
- protected: // переменные, которые будем передавать во второй класс
- int n, m;
- float **mas;
- public:
- chlen() {} // конструктор по умолчанию
- chlen(float **mas) { // конструктор с параметром
- this->mas = mas;
- }
- ~chlen() { // деструктор
- for (int i = 0; i < n; i++) {
- delete[] mas[i];
- }
- delete[] mas;
- }
- void setarray() { // выделение памяти под массив
- cout << "Введите размер матрицы: ";
- cin >> n >> m;
- cout << endl;
- mas = new float*[n];
- for (int i = 0; i < n; i++) {
- mas[i] = new float[m];
- }
- }
- void zapolnenie() { // рандомное заполнение массива, ничего необычного
- cout << "Введите массив: " << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cin >> mas[i][j];
- }
- }
- }
- void showarray() { // вывод массива на экран, тоже все как обычно
- cout << "Массив:" << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << mas[i][j] << "\t";
- }
- cout << endl;
- }
- }
- };
- class Jepa : public chlen
- {
- private:
- int max;
- float x;
- public:
- Jepa(){}
- Jepa(int max, float x) : chlen(mas)
- {
- this->max = max;
- this->x = x;
- }
- void fun1()
- {
- max = 0;
- for (int j = 0; j < m; j++) {
- for (int i = 0; i < n; i++) {
- if (mas[i][j] > max) {
- max = mas[i][j];
- }
- }
- mas[0][j] = max;
- max = 0;
- }
- }
- bool fun2()
- {
- cout << "Введите желаемую величину: ";
- cin >> x;
- for (int i = 0; i < n; i++) {
- if (mas[i] < &x)
- {
- return true;
- }
- }
- return false;
- }
- void fun3()
- {
- if (fun2() == true)
- {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- mas[n - 1][j] = mas[n - 1][j] / mas[0][j];
- }
- }
- }
- if(fun2() == false)
- {
- cout << "chlen" << endl;
- }
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- Jepa obj;
- obj.setarray();
- obj.zapolnenie();
- obj.fun1();
- obj.fun3();
- obj.showarray();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement