티스토리 뷰


#include <stdio.h>
#define SIZE 4

void main()
{
int a[SIZE][SIZE], b[SIZE][SIZE], c[SIZE][SIZE];
int i, j, n=0;

for (i = 0 ; i < SIZE ; i++)
for(j = 0 ; j < SIZE ; j++)
{
a[i][j] = ++n;
b[i][j] = n*n;
}

for(i = 0 ; i < SIZE ; i++)
for(j = 0 ; j < SIZE ; j++)
c[i][j] = a[i][j] + b[i][j];

printf("A = \n");

for(i = 0 ; i < SIZE ; i++)
for(j = 0 ; j < SIZE ; j++)
{
printf("%5d", a[i][j]);

if(j == SIZE - 1)
printf("\n");
}

for(i = 0 ; i < SIZE ; i++)
for(j = 0 ; j < SIZE ; j++)
{
printf("%5d", b[i][j]);

if(j == SIZE - 1)
printf("\n");
}

printf("\nC=A+B\n");

for(i = 0 ; i < SIZE ; i++)
for(j = 0 ; j < SIZE ; j++)
{
printf("%5d", c[i][j]);

if(j == SIZE - 1)
printf("\n");
}
}