I am new to programming, and think this code could be improved upon. Any suggestions?
#include <stdio.h>
#define size 10
void main()
{
int i,j,ii,jj,arr[size]={1,2,4,2,1,1,2,1,1,2};
int count=0, max_count=0, start_index=0, temp_start_index=0;
for(i=0;i<size;++i)
{
for (j=size-1;j>=0;--j)
{
for (ii=i,jj=j;;++ii,--jj)
{
if (arr[ii]==arr[jj])
{
if (count==0)
{
temp_start_index=ii;
}
++count;
if (ii==jj) //odd number of elements in palindrome
{
count=count*2-1;
break;
}else{
if (ii>jj) //even number of elements in palindrome
{
--count;
count=count*2;
break;
}
}
}
else
{
count=0;
break;
}
}
if (count>max_count)
{
max_count=count;
start_index=temp_start_index;
count=0;
temp_start_index=0;
}
}
}
for (i=start_index;i<start_index+max_count;++i)
{
printf("%d ",arr[i]);
}
printf("\n");
printf("%d\n",max_count);
}