Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
670 B
2
Indexable
Never
///palindrom array

#include <stdio.h>
int main()
{
    int n, b,flag=1,temp=0;
    scanf("%d", &n);
    
    int a[n], raw[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        raw[i]=a[i];
    }  
    for (int i = 0; i <= (n - 1) / 2; i++)
    {
        temp=a[i];
        a[i] = a[n - 1 - i];
        a[n - 1 - i] = temp;
    }
    for (int i = 0; i < n; i++)
    {
        if (raw[i]==a[i])
        {
            flag=1;
        }
        else{
            flag=0;
        }
    }
    if (flag==1)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    
    return 0;
}