
[Duda] matrices
Publicado por Daniel (2 intervenciones) el 27/04/2015 17:40:57
Queria consultar por un ej de matrices, no entiendo cual es el error, las funciones las declare de la misma forma que en los ej de vectores pero con un [] extra
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
matrices.h
#define FILA (4)
#define COL (4)
int sumatoria_matriz(int pmatriz[][]); // array type has incomplete element type
////////////////////////////////////////////
main.c
int main ()
{
int respuesta;
int pmatriz [FILA][COL]={{1,5,7,2},{2,6,2,1},{3,8,9,3},{4,1,3,2}};
respuesta=sumatoria_matriz(pmatriz); // type of formal parameter 1 is incomplete
printf("\n La respuesta es: ",respuesta);
}//fin
///////////////////////////////////////////////////////////////////////////
matrices.c
int sumatoria_matriz(int pmatriz[][])
{int opcion,i,j,sum=0;
do
{
printf("\n Seleccione Sumatoria a Realizar: ");
printf("\n 1) Sumatoria de la diagonal principal: ");
printf("\n 2) Sumatoria de la diagonal secundaria: ");
scanf("%d",opcion);
}while(opcion!=1 || opcion!=2);
if (opcion==1)
{
for (i=0;i<FILA-1;i++)
{
j=i;
sum=sum+pmatriz[i][j];
}
}
else
{
for (i=FILA-1;i>0;i--)
{
j=i;
sum=sum+pmatriz[i][j];
}
}
return (sum);
}
Valora esta pregunta


0