Write the definition of a function, isReverse, whose first two parameters are arrays of integers of equal size, and whose third parameter is an integer indicating the size of each array. The function returns true if and only if one array is the reverse of the other. (“Reverse” here means same elements but in reverse order.)

LANGUAGE: C++

CHALLENGE:

Write the definition of a function, isReverse, whose first two parameters are arrays of integers of equal size, and whose third parameter is an integer indicating the size of each array. The function returns true if and only if one array is the reverse of the other. (“Reverse” here means same elements but in reverse order.)

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

2 Comments

  1. Ben Large on June 30, 2016 at 9:30 pm

    Here is the code for C:

    int isReverse (int one[], int two[], int size){
    int matches=0;
    int k;
    for (k=0; k<size; k++){
    if (one[k] == two[size-k-1]){
    matches++;
    }
    }
    if (matches==size){
    return 1;
    }else{
    return 0;
    }
    }

  2. Don on December 19, 2016 at 12:01 am

    bool isReverse( int a[], int b[], int c)
    {
    for(int i=0; i<c; i++)
    {
    if(a[i]!=b[c-1-i])
    return false;
    else
    true;
    }
    return true;
    }
    for anyone who is doing the assignment, this is the best way to do it

Leave a Comment

You must be logged in to post a comment.