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.0125 sec