peshopbs2

Untitled

Jul 29th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #define MAXN 100
  3. using namespace std;
  4.  
  5. void input(int &number, int a[]) {
  6.     cin >> number;
  7.     for(int i = 0; i < number; i++) {
  8.         cin >> a[i];
  9.     }
  10. }
  11.  
  12. void output(int number, int a[]) {
  13.     for(int i = 0; i < number; i++) {
  14.         cout << a[i] << " ";
  15.     }
  16. }
  17.  
  18. bool is_symmetric(int n, int a[]) {
  19.     for (int i = 0, j = n-1; i <= j; i++, j--)
  20.     {
  21.         if(a[i]!=a[j]) {
  22.             return false;
  23.         }
  24.     }
  25.    
  26.     return true;
  27. }
  28.  
  29. int main() {
  30.     int n, a[MAXN];
  31.     input(n, a);
  32. //  output(n, a);
  33.     cout << "The array is symmetric: " << is_symmetric(n, a) << endl;
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment