Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <stdio.h>
- using namespace std;
- void print(int **A, const int N)
- {
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < N;j++)
- {
- cout << A[i][j] << "\t";
- }
- cout << endl;
- }
- }
- int pr_el(int** A, int N)
- {
- int pr = 1;
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < N;j++)
- {
- if ((i + j) % 4 == 0) pr *= A[i][j];
- }
- }
- cout << "Pr = " << pr;
- return pr;
- }
- int main()
- {
- ifstream file("C:\\Users\\Irinda\\source\\repos\\Задание 1\\text.txt");
- if (!file)
- {
- cout << "File is not open";
- return -1;
- }
- else
- {
- cout << "File is open" << endl;
- int N;
- file >> N;
- int **A;
- A = new int*[N];
- for (int i = 0;i < N;i++)
- {
- A[i] = new int [N];
- }
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < N;j++)
- {
- if (!file.eof())
- {
- file >> A[i][j];
- }
- }
- }
- cout << endl;
- print(A, N);
- cout << endl;
- pr_el(A, N);
- cout << endl;
- file.close();
- system("pause");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement