Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4. #include <stdio.h>
  5. #include <conio.h>
  6.  
  7.  
  8. using namespace std;
  9.  
  10. class matrix {
  11.  
  12. private:
  13.     double **matr;
  14.     int a;
  15. public:
  16.    
  17.     matrix() {
  18.         ifstream od;
  19.         od.open("test.txt");
  20.         od >> a;//f
  21.         matr = new double*[a];
  22.         for (int i = 0; i < a; i++) matr[i] = new double[a];
  23.  
  24.         for (int i = 0; i < a; i++) {
  25.             for (int j = 0; j < a; j++) {
  26.                 od >> matr[i][j];
  27.             }
  28.         }
  29.  
  30.     }
  31.  
  32.     void printM() {
  33.         for (int i = 0; i < a; i++) {
  34.             for (int j = 0; j < a; j++) {
  35.                 cout << matr[i][j] << " ";
  36.             }
  37.             cout << endl;
  38.         }
  39.     }
  40.  
  41.     void max() {
  42.         double max = DBL_MIN;
  43.         int m1, m2;
  44.         for (int i = 0; i < a; i++) {
  45.             for (int j = 0; j < a; j++) {
  46.                 if (max < matr[i][j]) {
  47.                     max = matr[i][j];
  48.                     m1 = i; m2 = j;
  49.                 }
  50.             }
  51.         }
  52.         cout << "Максимальное число: [" << m1 << "][" << m2 << "] = " << max << endl;
  53.  
  54.         for (int i = 0; i < a; i++) {
  55.             matr[a - i - 1][i] = max;
  56.         }
  57.         printM();
  58.        
  59.     }
  60.  
  61. };
  62.  
  63.  
  64. void main() {
  65.  
  66.     setlocale(LC_ALL, "Russian");
  67.  
  68.     int f, s;
  69.     matrix matr;
  70.     matr.printM();
  71.  
  72.     matr.max();
  73.    
  74.    
  75.     system("pause");
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement