#include <stdio.h>

int main(void)
{
        int mone[2][2], mtow[2][2];
        int i, j;
        int exit1, exit2;

        while(1)
        {
                printf("\n\n\n=========\n모든 행렬이 영행렬일 경우 종료합니다.\n\n");
                exit1=0;
                exit2=0;

                for(i=0; i<2; i++)
                {
                        for(j=0; j<2; j++)
                        {
                                printf("<<행렬 1의 %d%d열 원소를 입력하시오 : ",i+1 , j+1);
                                scanf("%d", &mone[i][j]);
                        }
                }
                printf(">>      행렬 1 입력완료!\n\n");

                for(i=0; i<2; i++)
                {
                        for(j=0; j<2; j++)
                        {
                                printf("<<행렬 2의 %d%d열 원소를 입력하시오 : ",i+1 , j+1);
                                scanf("%d", &mtow[i][j]);
                        }
                }
                printf(">>      행렬 2 입력완료!\n\n");

                printf("\n\n>>행렬 1 : \n");
                for(i=0; i<2; i++)
                {
                        printf("\n>>");
                        for(j=0; j<2; j++)
                        {
                                printf(" %d ", mone[i][j]);
                                exit1 = exit1 + mone[i][j];
                        }
                }

                printf("\n\n\n>>행렬 2 : \n");
                for(i=0; i<2; i++)
                {
                        printf("\n>>");
                        for(j=0; j<2; j++)
                        {
                                printf(" %d  ", mtow[i][j]);
                                exit2 = exit2 + mone[i][j];
                        }
                }

                if(exit1==0     &&      exit2==0)
                {
                        printf("\n\n종료합니다.\n");
                        break;
                }

                printf("\n\n\n>>두 행렬을 더한 행렬 : \n");
                for(i=0; i<2; i++)
                {
                        printf("\n>>");
                        for(j=0; j<2; j++)
                        {
                                printf(" %d  ", (mone[i][j]+mtow[i][j]));
                        }
                }
        }
        return 0;
}




--------------------------------------------------------------------------

현재 3x3 행렬의 곱셈을 짜는 중. 근데 뭔가 길어보여서 일단 포인터부터 공부해야겠다는 생각을

하는중.
Posted by 챠리나트
,