ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo021.c
Go to the documentation of this file.
1#include<stdio.h>
2
3#define N 100
4#define M 100
5
6int main(int argc, char *argv[])
7{
8 float A[N][M], B[N][M], C[N][M];
9 int nA, mA, nB, mB, i, j, k;
10 do{
11 printf("Ingrese el numero de filas de A: ");
12 scanf("%d", &nA);
13 }while(nA<1||nA>N);
14 do{
15 printf("Ingrese el numero de columnas de A: ");
16 scanf("%d", &mA);
17 }while(mA<1||mA>M);
18 do{
19 printf("Ingrese el numero de filas de B: ");
20 scanf("%d", &nB);
21 }while(nB!=mA);
22 do{
23 printf("Ingrese el numero de columnas de B: ");
24 scanf("%d", &mB);
25 }while(mB<1||mB>M);
26 for(i=0; i<nA; i++)
27 for(j=0; j<mA; j++)
28 {
29 printf("A[%d][%d] = ", i+1, j+1);
30 scanf("%f", &(A[i][j]));
31 }
32 for(i=0; i<nB; i++)
33 for(j=0; j<mB; j++)
34 {
35 printf("B[%d][%d] = ", i+1, j+1);
36 scanf("%f", &(B[i][j]));
37 }
38 for(i=0; i<nA; i++)
39 for(j=0; j<mB; j++)
40 {
41 for(k=0, C[i][j] = 0; k<mA; k++)
42 C[i][j] += (A[i][k]*B[k][j]);
43 printf("C[%d][%d] = %f\n", i+1, j+1, C[i][j]);
44 }
45 return 0;
46}
#define N
#define M
int main(void)
Definition Ejemplo_035.c:15