Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IFF - Introdução à Programação
- //Slide - Página 48 - Exercício 5
- #include<stdio.h>
- #include<locale.h>
- int main(){
- setlocale(LC_ALL,"Portuguese");
- int check=0;
- float aux=0,matriz1[3][2],matriz2[3][2],matriz[2][3],matriz3[3][3]={0};
- for(int l=0,c=0;l<3;l++){
- for(c=0;c<2;c++){
- printf("Entre com o valor da posição (%d,%d): ",l+1,c+1);
- if(check==0) scanf("%f",&matriz1[l][c]); else scanf("%f",&matriz2[l][c]);
- }
- if((l==2)&&(check==0)){
- check=1;
- l=-1;
- c=0;
- }
- }
- for(int l=0;l<2;l++){
- for(int c=0;c<3;c++){
- matriz[l][c]=matriz2[c][l];
- }
- }
- for(int l=0;l<3;l++){
- for(int c=0;c<3;c++){
- matriz3[l][c]=0;
- for(int k=0; k<2;k++){
- matriz3[l][c]+=matriz1[l][k]*matriz[k][c];
- }
- }
- }
- printf("\n\nA matriz 3, resultado da multiplicação das matrizes entradas anteriormente: \n");
- for(int l=0;l<3;l++){
- for(int c=0;c<3;c++){
- printf("%.0f ",matriz3[l][c]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment