In this exercise I am asked to write a funcion
to know if a number is MAYORITARIO
. That is, if there is an element stored in the vector that appears more than N / 2 times, where N is the number of vector elements
Error on line 15
#include <iostream>
using namespace std;
bool mayoritario(float v[],int n);
int n;
float v;
int main()
{
mayoritario(v,n);
cout<<mayoritario(v,n);
return 0;
}
bool mayoritario(float v[],int n){ //Linea 15
int i,j,nveces,nvmaximo=0;
for(int i=0 ;i<=n/2 ;i++){
nveces=1;
for(int j=i+1 ;j<n ;j++){
if(v[i]==v[j]){
nveces++;
}
if(nveces>nvmaximo){
nvmaximo=nveces;
}
}
}
return (nvmaximo>n/2);
}