SHARE
TWEET

Untitled

a guest May 24th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int min(int **mas, int rows, int cols);
  6.  
  7. int main()
  8. {
  9.     int rowsA = 4, colsA = 4, rowsB = 5, colsB = 5, rowsC = 3, colsC = 3;
  10.     int **A = new int* [rowsA];
  11.     int **B = new int* [rowsB];
  12.     int **C = new int* [rowsC];
  13.     for (int i = 0; i < rowsA; i++) {
  14.         A[i] = new int [colsA];
  15.     }
  16.     for (int i = 0; i < rowsB; i++) {
  17.         B[i] = new int [colsB];
  18.     }
  19.     for (int i = 0; i < rowsC; i++) {
  20.         C[i] = new int [colsC];
  21.     }
  22.     for(int i = 0; i < rowsA; i++) {
  23.         for(int j = 0; j < colsA; j++) {
  24.             cout << "Enter next element of matrix A ";
  25.             cin >> A[i][j];
  26.         }
  27.     }
  28.     for(int i = 0; i < rowsB; i++) {
  29.         for(int j = 0; j < colsB; j++) {
  30.             cout << "Enter next element of matrix B ";
  31.             cin >> B[i][j];
  32.         }
  33.     }
  34.     for(int i = 0; i < rowsC; i++) {
  35.         for(int j = 0; j < colsC; j++) {
  36.             cout << "Enter next element of matrix C ";
  37.             cin >> C[i][j];
  38.         }
  39.     }
  40.     int minA = min(A, rowsA, colsA);
  41.     int minB = min(B, rowsB, colsB);
  42.     int minC = min(C, rowsC, colsC);
  43.     cout << "A min * B min - C min = " << minA * minB - minC << endl;
  44.     for (int i = 0; i < rowsA; i++) {
  45.         delete[] A[i];
  46.     }
  47.     for (int i = 0; i < rowsB; i++) {
  48.         delete[] B[i];
  49.     }
  50.     for (int i = 0; i < rowsC; i++) {
  51.         delete[] C[i];
  52.     }
  53. }
  54.  
  55. int min(int **mas, int rows, int cols)
  56. {
  57.     int minValue = mas[0][0];
  58.     for(int i = 0; i < rows; i++) {
  59.         if(mas[i][i] < minValue)
  60.             minValue = mas[i][i];
  61.     }
  62.     return minValue;
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top