SHARE
TWEET

Untitled

a guest Jan 20th, 2020 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdio.h>
  4. using namespace std;
  5. void print(int **A, const int N)
  6. {
  7.     for (int i = 0;i < N;i++)
  8.     {
  9.         for (int j = 0;j < N;j++)
  10.         {
  11.             cout << A[i][j] << "\t";
  12.         }
  13.         cout << endl;
  14.     }
  15. }
  16. int pr_el(int** A, int N)
  17. {
  18.     int pr = 1;
  19.     for (int i = 0;i < N;i++)
  20.     {
  21.         for (int j = 0;j < N;j++)
  22.         {
  23.             if ((i + j) % 4 == 0) pr *= A[i][j];
  24.         }
  25.     }
  26.     cout << "Pr = " << pr;
  27.     return pr;
  28. }
  29. int main()
  30. {
  31.     ifstream file("C:\\Users\\Irinda\\source\\repos\\Задание 1\\text.txt");
  32.     if (!file)
  33.     {
  34.         cout << "File is not open";
  35.         return -1;
  36.     }
  37.     else
  38.     {
  39.         cout << "File is open" << endl;
  40.         int N;
  41.         file >> N;
  42.         int **A;
  43.         A = new int*[N];
  44.         for (int i = 0;i < N;i++)
  45.         {
  46.             A[i] = new int [N];
  47.         }
  48.         for (int i = 0;i < N;i++)
  49.         {
  50.             for (int j = 0;j < N;j++)
  51.             {
  52.                 if (!file.eof())
  53.                 {
  54.                     file >> A[i][j];
  55.                 }
  56.             }
  57.         }
  58.         cout << endl;
  59.         print(A, N);
  60.         cout << endl;
  61.         pr_el(A, N);
  62.         cout << endl;
  63.         file.close();
  64.         system("pause");
  65.         return 0;
  66.     }
  67. }
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
Top