Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define MAXN 100
- using namespace std;
- void input(int &number, int a[]) {
- cin >> number;
- for(int i = 0; i < number; i++) {
- cin >> a[i];
- }
- }
- void output(int number, int a[]) {
- for(int i = 0; i < number; i++) {
- cout << a[i] << " ";
- }
- }
- bool is_symmetric(int n, int a[]) {
- for (int i = 0, j = n-1; i <= j; i++, j--)
- {
- if(a[i]!=a[j]) {
- return false;
- }
- }
- return true;
- }
- int main() {
- int n, a[MAXN];
- input(n, a);
- // output(n, a);
- cout << "The array is symmetric: " << is_symmetric(n, a) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment