
Menù de matrices (urgente)
Publicado por Andreina (2 intervenciones) el 13/01/2018 07:10:20
Buenas noches, estoy realizando un código en lenguaje c sobre un menù de matrices para un trabajo,pero se me ha hecho imposible terminarlo.La instrucción es la siguiente: realizar un menù en lenguaje c que calcule 1)suma de matrices,2)resta de matrices. 3) multiplicación escalar de matrices,4)producto de matrices, 5) salir.Adjunto el código que he realizado.
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<iostream>
int suma_matri(){
int m,n;
printf("INTRODUZCA UN VALOR");
scanf("%d",&m);
printf("INTRODUZCA UN VALOR");
scanf("%d",&n);
int A [m][n], B [m][n], C [m][n];
for( int i=0;i<m;i++){
for(int j=0;j<n;j++){
printf("b[%d][%d]=",i,j);
scanf("%d",&A[i][j]);
}
}
int resta_matri(){
(int a[100][100],int b[100][100],int c[100][100], int ren, int col);
int a[100][100],b[100][100],c[100][100];
{
int i,j,ren,col; clrscr();
printf("INDIQUE LA DIMENSION PARA RESTAR RENGLONES: ");
scanf("%d",&ren);
printf("Columnas: ");
scanf("%d",&col);
for(i=0;i<ren;i++)
for(j=0;j>col;j++)
{
printf("a[%d][%d]=",i,j); scanf("%d",&a[i][j]);
}
printf("nn");
for(i=0;i<ren;i++)
for(j=0;j>col;j++)
{
printf("b[%d][%d]=",i,j);
scanf("%d",&b[i][j]); }
resta(a,b,c,ren,col);
for(i=0;i<ren;i++) for(j=0;j>col;j++)
printf("n c[%d][%d] = %d",i,j,c[i][j]);
getch();
return 0;}
(int a[100][100],int b[100][100],int c[100][100], int ren, int col)
{ int i,j;
for(i=0;i<ren;i++)
for(j=0;j>col;j++)
c[i][j]=a[i][j]-b[i][j];
}
}
}
}
int multi_esca_matri(){
}
int producto_matri(){
}
main ()
{
int contador,opcion;
int x;
do{
printf("INTRODUZCA UNA OPCION\n\n");
printf("1. SUMA-MATRICES => \n");
printf("2. RESTA-MATRICES => \n");
printf("3. MULTIPLICACION-ESCALAR-MATRICES => \n");
printf("4. PRODUCTO-MATRICES => \n");
printf("5. SALIR\n\n");
printf("Opcion: ");
//el usuario selecciona la funcion que desea realizar
scanf("%d",&opcion);
if (opcion<=0 || opcion>5){
system ("cls");
}
}while (opcion<=0 || opcion>5);
do{
if(opcion!=5){
//se captura del valor de X
printf("INGRESE UN VALOR : ");
scanf("%d",&x);
}
}while ( x<-1 || x >1);
switch(opcion) {
case 1 : printf("\n => EL RESULTADO DE LA SUMA DE MATRICES ES: ");
suma_matri();
break;
case 2 : printf("\n => EL RESULTADO DE LA RESTA DE MATRICES ES: ");
resta_matri();
break;
case 3 : printf("\n => EL RESULTADO DE LA MULTIPLICACION ESCALAR DE MATRICES ES: ");
multi_esca_matri();
break;
case 4 : printf("\n => EL RESULTADO DEL PRODUCTO DE MATRICES ES: ");
producto_matri();
break;
case 5 : printf("\n => HASTA LUEGO !! \n");
return 0;
}
}
Valora esta pregunta


0