Domanda di colloquio di Valeo

Write an algorithm to check an array is a mirror array.

Risposte di colloquio

Anonimo

19 nov 2020

int main() { int flag=-1; int ar[5]={4,1,5,1,4}; for(int forword=0,bw=4;forword=0;forword++,bw--){ if(ar[forword]==ar[bw]){flag=1;} else{flag=-1;break;} //for(int bw=4;bw>=0;bw--) } flag==1?printf("ok"):printf("not ok"); }

Anonimo

23 ott 2015

A mirror array is .i.e 123321. loop until size/2 -1 and compare both i and (size-1)-i

6