mercredi 1 juillet 2015

C++ equivalent array

The question can be found here:http://ift.tt/1R6kVOW

here's my function:

    #include<iostream>
    using namespace std;
    bool equivalent(int a[], int b[], int n)
    {
       int i=0, j=0, count =0;
        while (a[i]!=b[j])
       {

           count++;
           j++;
       }

     for(int i=0; i<=n; i++)
       if(a[i]%n==b[i+count]%n)
          return true;
       else return false;
    }

please advise, thanks in advance!

Aucun commentaire:

Enregistrer un commentaire