No older revisions available
No older revisions available
코드 ¶
~cpp
#include <iostream>
using namespace std;
const int SIZE = 4;
void input_arr(int arr[][SIZE]);
void find_max(int arr[][SIZE]);
void show_arr(int arr[][SIZE]);
int main()
{
int arr[SIZE][SIZE];
input_arr(arr);
find_max(arr);
show_arr(arr);
return 0;
}
void input_arr(int arr[][SIZE])
{
for (int i = 0; i < SIZE - 1; i++)
for (int j = 0; j < SIZE - 1; j++)
cin >> arr[i][j];
}
void find_max(int arr[][SIZE])
{
arr[SIZE-1][SIZE-1] = arr[0][0];
for (int i = 0; i < SIZE-1; i++)
{
arr[i][SIZE-1] = arr[i][0];
arr[SIZE-1][i] = arr[0][i];
for (int j = 1; j < SIZE-1; j++)
{
if (arr[i][SIZE-1] < arr[i][j])
arr[i][SIZE-1] = arr[i][j];
if (arr[SIZE-1][i] < arr[j][i])
arr[SIZE-1][i] = arr[j][i];
}
if (arr[SIZE-1][SIZE-1] < arr[i][SIZE-1])
arr[SIZE-1][SIZE-1] = arr[i][SIZE-1];
}
}
void show_arr(int arr[][SIZE])
{
for (int i = 0; i < SIZE; i++)
{
for (int j = 0; j < SIZE; j++)
cout << arr[i][j] << '\t';
cout << endl;
}
}