U E D R , A S I H C RSS

큰수찾아저장하기/문보창

소감

코드

~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; 
        } 
} 
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:20
Processing time 0.0130 sec