#include #define TAM 40 void LeMatriz(int n, double M[TAM][TAM]) { int i, j; puts("Entre com os valores:"); for (i = 0; i < n; i++) { printf("Linha %2d\n", i); for (j = 0; j < n; j++) { printf("\tColuna %2d\n", j); scanf("%lf", &M[i][j]); } } } void LeVetor(int n, double M[TAM]) { int i; puts("Entre com os valores:"); for (i = 0; i < n; i++) scanf("%lf", &M[i]); } void ImprimeMatriz(int n, double M[][TAM]) { int i, j; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) printf("%7.3f", M[i][j]); putchar('\n'); } } void ImprimeVetor(int n, double M[]) { int i; for (i = 0; i < n; i++) { printf("%7.3f", M[i]); putchar('\n'); } } /* c = a * b */ void Multiplica(int n, double c[TAM],double a[TAM][TAM], double b[TAM]) { int i, j; for (i = 0; i < n; i++) { c[i] = 0.; for (j = 0; j < n; j++) c[i] += a[i][j]*b[j]; } } int main() { double m[TAM][TAM], x[TAM], y[TAM]; int n; printf("Qual o tamanho da matriz? "); scanf("%d", &n); LeMatriz(n, m); puts("------------------"); ImprimeMatriz(n, m); LeVetor(n, x); puts("------------------"); ImprimeVetor(n, x); /* y = m * x */ Multiplica(n, y, m, x); puts("------------------"); ImprimeVetor(n, y); puts("------------------"); return 0; }