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 F[][8], int N, int M)
- {
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < M;j++)
- {
- cout << F[i][j] << "\t";
- }
- cout << endl;
- }
- }
- int max_nech(int F[][8], int N, int M)
- {
- int nech = F[0][0];
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < M;j++)
- {
- if (F[i][j] % 2 != 0) nech = F[i][j];
- }
- }
- int max = nech;
- int numbi = 0, numbj = 0;
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < M;j++)
- {
- if (F[i][j] % 2 != 0)
- {
- if (F[i][j] > max)
- {
- max = F[i][j];
- numbi = i;
- numbj = j;
- }
- }
- }
- }
- cout << "max = " << max << " " << "ind: " << numbi << " " << numbj << endl;
- return max;
- }
- 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 = 6;
- const int M = 8;
- int F[N][M];
- for (int i = 0;i < N;i++)
- {
- for (int j = 0;j < M;j++)
- {
- if (!file.eof())
- {
- file >> F[i][j];
- }
- }
- }
- cout << endl;
- print(F, N, M);
- cout << endl;
- max_nech(F, N, M);
- file.close();
- system("pause");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement