Dev - C++ - Matriz

 
Vista:

Matriz

Publicado por Uziel (1 intervención) el 30/03/2020 22:22:43
ayuda porfavor lo tengo que convertir a lenguaje C, este en C++


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
using namespace std;
int main(){
 int m,n;
 cout<<"Suma de matrices mxn"<<endl;
 cout<<"Ingrese m: ";
 cin>>m;
 cout<<"Ingrese n: ";
 cin>>n;
 cout<<"*****"<<endl;
 int mat1[m][n], mat2[m][n];
 
 cout<<"Llenado de matriz 1"<<endl;
 for(int i=0;i<m;i++){
  for(int j=0;j<n;j++){
   cout<<"Ingrese numero: ";
   cin>>mat1[i][j];
  }
 }
 cout<<"\n";
 cout<<"*****"<<endl;
 cout<<"Llenado de matriz 2"<<endl;
 for(int i=0;i<m;i++){
  for(int j=0;j<n;j++){
   cout<<"Ingrese numero: ";
   cin>>mat2[i][j];
  }
 }
 cout<<"\n";
 cout<<"La matriz 1 es: "<<endl;
 for(int i=0;i<m;i++){
  for(int j=0;j<n;j++){
   cout<<mat1[i][j]<<" ";
 
  }
  cout<<endl;
 
 }
 cout<<"\n";
 cout<<"La matriz dos es: "<<endl;
 for(int i=0;i<m;i++){
  for(int j=0;j<n;j++){
   cout<<mat2[i][j]<<" ";
 
  }
  cout<<endl;
 
 }
 
 cout<<"\n";
 cout<<"La suma de las dos matrices es:"<<endl;
 for(int i=0;i<m;i++){
  for(int j=0;j<n;j++){
   cout<<mat1[i][j]+mat2[i][j]<<" ";
 
  }
  cout<<endl;
 
 }
 return 0;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 1.440
Bronce
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

Matriz

Publicado por dario (718 intervenciones) el 31/03/2020 11:15:22
Hola, te dejo esto.
Salu2.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
 
int main() {
    int m,n;
 
    printf("Suma de matrices m x n\n");
    printf("Ingrese m: ");
    scanf("%d",&m);
    printf("Ingrese n: ");
    scanf("%d",&n);
    printf("*****\n");
 
    int mat1[m][n], mat2[m][n], mat3[m][n];
 
    printf("Llenado de matriz 1\n");
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            printf("Ingrese numero: ");
            scanf("%d",&mat1[i][j]);
        }
    }
    printf("\n");
    printf("*****\n");
 
    printf("Llenado de matriz 2\n");
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            printf("Ingrese numero: ");
            scanf("%d",&mat2[i][j]);
        }
    }
    printf("\n");
    printf("La matriz 1 es: \n");
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            printf("%d ",mat1[i][j]);
        printf("\n");
 
    printf("\n");
    printf("La matriz 2 es: \n");
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            printf("%d ",mat2[i][j]);
        printf("\n");
 
    printf("\n");
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            mat3[i][j] = mat1[i][j]+mat2[i][j];
        }
    }
 
        printf("La suma de las dos matrices es:\n");
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                printf("%d ",mat3[i][j]);
            }
            printf("\n");
        }
 
    return 0;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar