Advertisement
win98se

identicalarrays.cpp

Dec 26th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool isEqual(const int list1[], const int list2[], int size)
  6. {
  7.     bool result=true;
  8.     for(int c=0; c<size; c++)
  9.     {
  10.         if(list1[c]!=list2[c])
  11.             result=false;
  12.     }
  13.     return(result);
  14. }
  15.  
  16. int main()
  17. {
  18.     int sizeofarray;
  19.     cout<<"Enter size of array: ";
  20.     cin>>sizeofarray;
  21.     int list1[sizeofarray], list2[sizeofarray];
  22.     cout<<"\nEnter the first list, one integer per line:\n";
  23.     for(int i=0; i<sizeofarray; i++)
  24.     {
  25.         cout<<(i+1)<<": ";
  26.         cin>>list1[i];
  27.     }
  28.     cout<<"\nEnter the second list, one integer per line:\n";
  29.     for(int j=0; j<sizeofarray; j++)
  30.     {
  31.         cout<<(j+1)<<": ";
  32.         cin>>list2[j];
  33.     }
  34.     if(isEqual(list1, list2, sizeofarray))
  35.         cout<<"\nThe two arrays are identical.\n";
  36.     else
  37.         cout<<"\nThe two arrays are not identical.\n";
  38.     return(0);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement