It is confusing. What does the area array stores ? Is the data a number or string. Sometimes you give it a value of 1,0 and sometimes you assing "0","1" to it. And you have a conditional statement if (area[x][x]=="0"){};

I am afraid I have no time to debug them in details. Just a glance.