U E D R , A S I H C RSS

큰수찾아저장하기/허아영

, 각각 ..
.
for .
까??

. matrix temp1,2 matrix ..
matrix .

  • sort 계기 .
    고.. ^^

: - , 까 궁,
까 ? 그고 C 까?
. 그 , .

~cpp 
#include <stdio.h>
#define MATRIX_SIZE 4

void search_max(int matrix[][MATRIX_SIZE]);
void print_matrix(int matrix[][MATRIX_SIZE]);
void change(int *, int *);

int i, j;
void main()
{
	int matrix[MATRIX_SIZE][MATRIX_SIZE] = {{0,}};
	//3 * 3  .
	for(i = 0; i < MATRIX_SIZE - 1; i++){
		for(j = 0; j < MATRIX_SIZE -1; j++){
			printf("matrix[%d][%d] = ", i, j);
			scanf("%d", &matrix[i][j]);
		}
	}
	//    기.
	search_max(matrix);
	//
	print_matrix(matrix);
}

void search_max(int matrix[][MATRIX_SIZE])
{
	int temp_matrix[4][4], a, b;
	for(i = 0; i < MATRIX_SIZE; i++){
		for(j = 0; j < MATRIX_SIZE; j++){
			temp_matrix[i][j] = matrix[i][j];
		}
	}
	// 
	for(i = 0; i < MATRIX_SIZE-1; i++){
		for(j = 0; j < MATRIX_SIZE-2; j++){
			if(temp_matrix[i][j] > temp_matrix[i][j+1]){
				change(&temp_matrix[i][j], &temp_matrix[i][j+1]);
			}
		}
		matrix[i][MATRIX_SIZE-1] = temp_matrix[i][MATRIX_SIZE-2];
	}
	for(i = 0; i < MATRIX_SIZE; i++){
		for(j = 0; j < MATRIX_SIZE; j++){
			temp_matrix[i][j] = matrix[i][j];
		}
	}
	// 
	for(i = 0; i < MATRIX_SIZE-1; i++){
		for(j = 0; j < MATRIX_SIZE-2; j++){
			if(temp_matrix[j][i] > temp_matrix[j+1][i]){
				change(&temp_matrix[j][i], &temp_matrix[j+1][i]);
			}
		}
		matrix[MATRIX_SIZE-1][i] = temp_matrix[MATRIX_SIZE-2][i];
	}
	// 
	for(i = 0; i < MATRIX_SIZE-2; i++){
		if(temp_matrix[MATRIX_SIZE-1][i] > temp_matrix[MATRIX_SIZE-1][i+1]){
				change(&temp_matrix[MATRIX_SIZE-1][i], &temp_matrix[MATRIX_SIZE-1][i+1]);
			}
		if(temp_matrix[i][MATRIX_SIZE-1] > temp_matrix[i+1][MATRIX_SIZE-1]){
				change(&temp_matrix[i][MATRIX_SIZE-1], &temp_matrix[i+1][MATRIX_SIZE-1]);
			}
	}
	a = temp_matrix[MATRIX_SIZE-1][MATRIX_SIZE-2];
	b = temp_matrix[MATRIX_SIZE-2][MATRIX_SIZE-1];
	matrix[MATRIX_SIZE-1][MATRIX_SIZE-1] =  a > b ? a : b;

}
void print_matrix(int matrix[][MATRIX_SIZE])
{
	for(i = 0; i < MATRIX_SIZE; i++){
		for(j = 0; j < MATRIX_SIZE; j++){
			printf("%5d", matrix[i][j]);
		}
		if(j == MATRIX_SIZE)
			printf("\n");
	}
}
void change(int *a, int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

각 기 ..^^ 그게 ..ㅎㅎ
..^^ -

? ..;;
.. ??;;;;;
~ -

~ 고 ㅋㅋ , ..^^;; --
... ..ㅎㅎ -

-_-;; --
....ㅎㅎ ..ㅎㅎ -
구 ㅋㅋ ㅋㅋ --
..ㅎㅎㅎ 고...ㅎㅎㅎ 그 길..ㅎㅎㅎ -


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:21
Processing time 0.0136 sec