// PROGRAMA PARA SUMAR Y MULTIPLICAR
// DOS MATRICES DE (n x n)
//Copyright (c) Henry Mendiburu#include
#include
int n, fil, col, x,y;
int A[4][4];
int B[4][4];
int C[4][4];
int D[4][4];
main()
{
clrscr();
printf("\nIgresar orden de la matriz (n<=4) : ");
scanf("%d",&n);
if(n>4)
printf("\n\nFuera de rango");
else
{
fil=n;
col=n;
clrscr();
gotoxy(5,3);
printf("Ingresar Matriz A :");
for(x=1;x<=fil;x++)
for(y=1;y<=col;y++)
{
gotoxy(3*y+5,3*x+5);
scanf("%d",&A[x][y]);
}
gotoxy(35,3);
printf("Ingresar Matriz B : ");
for(x=1;x<=fil;x++)
for(y=1;y<=col;y++)
{
gotoxy(3*y+35,3*x+5);
scanf("%d",&B[x][y]);
}
gotoxy(5,22);
printf("SUMA de A + B");
for(x=1;x<=fil;x++)
for(y=1;y<=col;y++)
{
gotoxy(4*y+5,3*x+25);
C[x][y] = A[x][y] + B[x][y] ;
printf("%d", C[x][y]);
}
gotoxy(35,22);
printf("MULTIPLICACION de A * B");
//D[x][y] = A[x][1] * B[1][y] + A[x][2] * B[2][y] + A[x][3] * B[3][y];
//D[x][2] = A[x][1] * B[1][2] + A[x][2] * B[2][2] + A[x][3] * B[3][2];
//D[x][3] = A[x][1] * B[1][3] + A[x][2] * B[2][3] + A[x][3] * B[3][3];
for(x=1;x<=fil;x++)
for(y=1;y<=col;y++)
{
gotoxy(5*y+35,3*x+25);
D[x][y] = A[x][1] * B[1][y] + A[x][2] * B[2][y] + A[x][3] * B[3][y]; ;
printf("%d", D[x][y]);
}
}
getch();
return 0;
}