dimanche 28 juillet 2019

error: control reaches end of non-void function [-Werror=return-type] } ^

The problem is basically about to generate a arithmetic expression from a given 'n' numbers , and the expression should be divisible by 101. we can only have +,-,* operators and expression is left associative.

I have tried all the available solution on , that are already mentioned on stack overflow, like closing the expressions with else and many more

bool calci(int a[],int n,int sum,int pos,char operato[],deque<int>&q,deque<char>&qc)
{

    if(sum%101==0)
    {   //cout<<"sum:"<<sum<<endl;
        return true;
    }

    else if(pos==n)
        {return false;}
    else
    {
    for(int k=0;k<3;k++)
    {  // cout<<"here for "<<a[pos]<<endl;
        sum=addto(sum,a[pos],operato[k]);
        qc.push_back(operato[k]);
        q.push_back(a[pos]);
        bool kyaagesemila=calci(a,n,sum,pos+1,operato,q,qc);
        if(kyaagesemila)
            {
                return true;
            }
        sum=removefrom(sum,a[pos],operato[k]);
        qc.pop_back();
        q.pop_back();
    }
    }
}

i am getting a compilation error

solution.cc:53:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1plus: some warnings being treated as errors```


Aucun commentaire:

Enregistrer un commentaire