Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/09/2012, 08:18
antonio715
 
Fecha de Ingreso: agosto-2012
Ubicación: Alcalá
Mensajes: 37
Antigüedad: 11 años, 8 meses
Puntos: 0
error [Linker error] undefined reference to `mayoritario(float, float)'

Hola, he escrito un programita para comprobar si un vector es mayoritario (si el vector tiene la mayoría de los elementos iguales es mayoritario).
Lo compilo y me da el error:

[Linker error] undefined reference to `mayoritario(float, float)'
ld returned 1 exit status


que no entiendo, yo creo que está todo bien no sé si vosotros veis algo raro.

Gracias.



Código c++:
Ver original
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7. bool mayoritario (float, float);
  8. bool mayoritario (float vector [10], float n)
  9. {
  10.      int suma=0;
  11.      for (int i=0; i<n; i++)
  12.          for (int j=0; j<n && suma<=(n/2); j++)
  13.           if (vector [i]==vector[j])
  14.            suma++;
  15.            
  16.      if (suma>(n/2))
  17.      return true;
  18.      else
  19.      return false;
  20.      
  21.      
  22.    
  23. }
  24.  
  25.                                
  26. int main()
  27. {
  28.     float vector [10],n;
  29.     cout <<"Cuantos elementos?";
  30.     cin>>n;
  31.     cout<<"Escriba los"<<n<<" numeros: ";
  32.     for (int i=0; i<n;i++)
  33.     cin>>vector [i];
  34.    
  35.    
  36.     if (mayoritario (vector [10], n))
  37.     cout<<"El vector es mayoritario"<<endl;
  38.     else
  39.     cout<<"El vector no es mayoritario"<<endl;
  40.        
  41.     system("PAUSE");
  42.     return EXIT_SUCCESS;
  43.  
  44. }