#include
using namespace std;
int main() {
int t,i,j,n,a[100],b[100],k=0;
cin>>t;
while(t--)
{
cin>>n;
for(i=0,j=n-1;i<n;i++,j--)
{
cin>>a[i];
if(a[i]>7)
{
break;
}
b[j]=a[i];
}
for(i=0;i<n;i++)
{
if(a[i]==b[i])
{
k=1;
}else
{
k=0;
break;
}
}
if(k==0)
{
cout<<"no"<<endl;
}else
{
cout<<"yes"<<endl;
}
}
return 0;
}
And I want to know Why this One is correct ?
#include<stdio.h>
main()
{
int t,i;
scanf("%d",&t);
while(t--)
{
int n,c=0;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n/2;i++)
{
if(a[i]==a[n-i-1])
c++;
}
if(c==n/2 && a[n/2]==7)
printf("yes\n");
else
printf("no\n");
}
}
Please Reply ASAP
Thank you