AYUDA error de compilación en C++
Publicado por Luis Alberto Guisado Mena (4 intervenciones) el 04/06/2011 04:38:38
Quisiera que alguien me diga el error que estoy cometiendo en esta codificación. Uso el Borland C++ 5.02
Estoy practicando el uso de funciones y cuando compilo este programa me sale un error que dice más o menos así: " Cannot convert 'float ( *)[10]' to 'float' "
El código es el siguiente:
include <iostream.h>
# include <stdlib.h>
# include <conio.h>
# include <stdio.h>
# include <windows.h>
# define subraya "-----------------------------------"
//1. DECLARACIÓN DE FUNCIONES (PROTOTIPOS) ////////////////////////////////////////…
void Rango();
void LlenarM(float);
void Opc();
void RealizaOp(char);
void MostrarM(float);
//2. DECLARACIÓN DE VARIABLES GLOBALES ////////////////////////////////////////…
int f, c;
float A[10][10], B[10][10], C[10][10];
//3. DEFINICIÓN DE FUNCIONES (IMPLEMENTACIÓN DE LOS PROTOTIPOS)
//FUNCIÓN QUE PERMITE LA ENTRADA DE FILAS Y COLUMNAS DE UNA MATRIZ
void Rango()
{
clrscr();
system("title DIMENSIONES DE MATRIZ"); system("color 1e");
gotoxy(15,5); cout<<"DIMENSIONES DE LA MATRIZ";
gotoxy(10,6); cout<<subraya;
gotoxy(10,12); cout<<"# FILAS = "; cin>>f;
gotoxy(10,13); cout<<"# COLUMNAS = "; cin>>c;
}
//FUNCIÓN QUE PERMITE EL LLENADO DE LOS ELEMENTOS DE UNA MATRIZ
void LlenarM(float M[10][10])
{
int i,j;
clrscr();
system("title LLENADO DE LA MATRIZ");
system("color 1e");
gotoxy(15,3); cout<<"LLENADO DE LA MATRIZ";
gotoxy(10,4); cout<<subraya;
//GENERA LAS LÍNEAS QUE DELIMITAN LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f+1;i++)
{gotoxy(4,i+6); cout<<"|";
gotoxy(7*(c-1)+12,i+6); cout<<"|";
}
gotoxy(5,5); cout<<"_";
gotoxy(5,f+7); cout<<"_";
gotoxy(7*(c-1)+11,5); cout<<"_";
gotoxy(7*(c-1)+11,f+7); cout<<"_";
//LECTURA DE LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f-1;i++)
for(j=0;j<=c-1;j++)
{
gotoxy(j*7+8,i+7); cin>>M[i][j];
}
}
//MENÚ PRINCIPAL
void Opc()
{
char resp;
system("title OPCIONES DEL PROGRAMA");
clrscr();
system("color 1e");
gotoxy(15,3); cout<<"MENU DE OPCIONES";
gotoxy(10,4); cout<<subraya;
Sleep(500); gotoxy(5,6); cout<<"A) Mostrar la matriz almacenada ";
Sleep(500); gotoxy(5,8); cout<<"B) Calcular la traza ";
Sleep(500); gotoxy(5,10); cout<<"C) Calcular el determinante ";
Sleep(500); gotoxy(5,12); cout<<"D) SALIR"; Sleep(500);
do{
gotoxy(5,16); clreol(); system("color 1e"); cout<<"Ingrese opcion ===> "; cin>>resp;
if(resp!='A' && resp!='B' && resp!='C' && resp!='D' && resp!='a' && resp!='b' && resp!='c' && resp!='d')
{gotoxy(14,14); textcolor(LIGHTRED); cprintf(" :( Opcion no valida");
}
else
{gotoxy(5,14); clreol(); system("color 1e");
}
}while(resp!='A' && resp!='B' && resp!='C' && resp!='D' && resp!='a' && resp!='b' && resp!='c' && resp!='d');
if(resp=='a') resp='A';
if(resp=='b') resp='B';
if(resp=='c') resp='C';
if(resp=='d') resp='D';
getchar();
RealizaOp(resp);
}
// FUNCION QUE REALIZA LA OPCION ELEGIDA EN EL MENU DE OPCIONES
void RealizaOp(char r)
{
switch(r)
{
case'A':
MostrarM(A);
break;
case'B':
{
}
break;
case'C':
{
}
break;
case'D':
{
}
break;
}
}
// FUNCION QUE MUESTRA UNA MATRIZ
void MostrarM(float M[10][10])
{
int i,j;
clrscr();
system("color 1e");
system("title MOSTRAR LA MATRIZ");
gotoxy(15,3); cout<<"MOSTRANDO LA LA MATRIZ";
gotoxy(10,4); cout<<subraya;
//GENERA LAS LÍNEAS QUE DELIMITAN LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f+1;i++)
{gotoxy(4,i+6); cout<<"|";
gotoxy(7*(c-1)+12,i+6); cout<<"|";
}
gotoxy(5,5); cout<<"_";
gotoxy(5,f+7); cout<<"_";
gotoxy(7*(c-1)+11,5); cout<<"_";
gotoxy(7*(c-1)+11,f+7); cout<<"_";
//MOSTRANDO LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f-1;i++)
for(j=0;j<=c-1;j++)
{
gotoxy(j*7+8,i+7); cout<<M[i][j];
}
}
//4. PROGRAMA PRINCIPAL ////////////////////////////////////////…
int main(void)
{
Rango();
LlenarM(A);
Opc();
return 0;
}
Estoy practicando el uso de funciones y cuando compilo este programa me sale un error que dice más o menos así: " Cannot convert 'float ( *)[10]' to 'float' "
El código es el siguiente:
include <iostream.h>
# include <stdlib.h>
# include <conio.h>
# include <stdio.h>
# include <windows.h>
# define subraya "-----------------------------------"
//1. DECLARACIÓN DE FUNCIONES (PROTOTIPOS) ////////////////////////////////////////…
void Rango();
void LlenarM(float);
void Opc();
void RealizaOp(char);
void MostrarM(float);
//2. DECLARACIÓN DE VARIABLES GLOBALES ////////////////////////////////////////…
int f, c;
float A[10][10], B[10][10], C[10][10];
//3. DEFINICIÓN DE FUNCIONES (IMPLEMENTACIÓN DE LOS PROTOTIPOS)
//FUNCIÓN QUE PERMITE LA ENTRADA DE FILAS Y COLUMNAS DE UNA MATRIZ
void Rango()
{
clrscr();
system("title DIMENSIONES DE MATRIZ"); system("color 1e");
gotoxy(15,5); cout<<"DIMENSIONES DE LA MATRIZ";
gotoxy(10,6); cout<<subraya;
gotoxy(10,12); cout<<"# FILAS = "; cin>>f;
gotoxy(10,13); cout<<"# COLUMNAS = "; cin>>c;
}
//FUNCIÓN QUE PERMITE EL LLENADO DE LOS ELEMENTOS DE UNA MATRIZ
void LlenarM(float M[10][10])
{
int i,j;
clrscr();
system("title LLENADO DE LA MATRIZ");
system("color 1e");
gotoxy(15,3); cout<<"LLENADO DE LA MATRIZ";
gotoxy(10,4); cout<<subraya;
//GENERA LAS LÍNEAS QUE DELIMITAN LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f+1;i++)
{gotoxy(4,i+6); cout<<"|";
gotoxy(7*(c-1)+12,i+6); cout<<"|";
}
gotoxy(5,5); cout<<"_";
gotoxy(5,f+7); cout<<"_";
gotoxy(7*(c-1)+11,5); cout<<"_";
gotoxy(7*(c-1)+11,f+7); cout<<"_";
//LECTURA DE LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f-1;i++)
for(j=0;j<=c-1;j++)
{
gotoxy(j*7+8,i+7); cin>>M[i][j];
}
}
//MENÚ PRINCIPAL
void Opc()
{
char resp;
system("title OPCIONES DEL PROGRAMA");
clrscr();
system("color 1e");
gotoxy(15,3); cout<<"MENU DE OPCIONES";
gotoxy(10,4); cout<<subraya;
Sleep(500); gotoxy(5,6); cout<<"A) Mostrar la matriz almacenada ";
Sleep(500); gotoxy(5,8); cout<<"B) Calcular la traza ";
Sleep(500); gotoxy(5,10); cout<<"C) Calcular el determinante ";
Sleep(500); gotoxy(5,12); cout<<"D) SALIR"; Sleep(500);
do{
gotoxy(5,16); clreol(); system("color 1e"); cout<<"Ingrese opcion ===> "; cin>>resp;
if(resp!='A' && resp!='B' && resp!='C' && resp!='D' && resp!='a' && resp!='b' && resp!='c' && resp!='d')
{gotoxy(14,14); textcolor(LIGHTRED); cprintf(" :( Opcion no valida");
}
else
{gotoxy(5,14); clreol(); system("color 1e");
}
}while(resp!='A' && resp!='B' && resp!='C' && resp!='D' && resp!='a' && resp!='b' && resp!='c' && resp!='d');
if(resp=='a') resp='A';
if(resp=='b') resp='B';
if(resp=='c') resp='C';
if(resp=='d') resp='D';
getchar();
RealizaOp(resp);
}
// FUNCION QUE REALIZA LA OPCION ELEGIDA EN EL MENU DE OPCIONES
void RealizaOp(char r)
{
switch(r)
{
case'A':
MostrarM(A);
break;
case'B':
{
}
break;
case'C':
{
}
break;
case'D':
{
}
break;
}
}
// FUNCION QUE MUESTRA UNA MATRIZ
void MostrarM(float M[10][10])
{
int i,j;
clrscr();
system("color 1e");
system("title MOSTRAR LA MATRIZ");
gotoxy(15,3); cout<<"MOSTRANDO LA LA MATRIZ";
gotoxy(10,4); cout<<subraya;
//GENERA LAS LÍNEAS QUE DELIMITAN LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f+1;i++)
{gotoxy(4,i+6); cout<<"|";
gotoxy(7*(c-1)+12,i+6); cout<<"|";
}
gotoxy(5,5); cout<<"_";
gotoxy(5,f+7); cout<<"_";
gotoxy(7*(c-1)+11,5); cout<<"_";
gotoxy(7*(c-1)+11,f+7); cout<<"_";
//MOSTRANDO LOS ELEMENTOS DE LA MATRIZ
for(i=0;i<=f-1;i++)
for(j=0;j<=c-1;j++)
{
gotoxy(j*7+8,i+7); cout<<M[i][j];
}
}
//4. PROGRAMA PRINCIPAL ////////////////////////////////////////…
int main(void)
{
Rango();
LlenarM(A);
Opc();
return 0;
}
Valora esta pregunta


0