Write a program equals.cpp the implements the function bool equals(int a[], int a_size, int b[], int b_size) that checks whether two arrays with integer elements have the same elements in the same order. Assume that the user will enter a maximum of 100 integers. Also, you may NOT use any other headers besides and .

Respuesta :

Answer:

The program is as follows:

#include<iostream>

using namespace std;

bool equals(int a[], int a_size, int b[], int b_size){

    bool chk = true;

    for(int i =0; i<a_size;i++){

        if(a[i] != b[i]){

         chk = false; break;           }     }

    return chk;

}

int main(){

   int a_size,b_size;

   cin>>a_size;

   b_size = a_size;

   int a[a_size],b[b_size];

   for(int i =0; i<a_size;i++){        cin>>a[i];    }

   for(int i =0; i<a_size;i++){        cin>>b[i];    }

   cout<<equals(a,a_size, b, b_size);

   return 0;

}

Explanation:

See attachment for source file where comments are used to explain some lines

Ver imagen MrRoyal