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[][10], int N)
- {
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < N;j++)
- {
- cout << A[i][j] << "\t";
- }
- cout << endl;
- }
- }
- double sr_arifm(int A[][10], int N)
- {
- double sum = 0;
- int kol = 0;
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < N;j++)
- {
- if (i < j)
- {
- sum += A[i][j];
- kol++;
- }
- }
- }
- return sum/kol;
- }
- 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;
- const int N = 10;
- int A[N][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;
- cout << "Sr arifm = " << sr_arifm(A, N)<<endl;
- file.close();
- system("pause");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement