class trans {
	
	int m,n,l=0,k=-1,total,no=0;
	void det(int t)
	{ 
	   total=t;
	}
	char[][] s5=new char[total][total];
	char[][] s6=new char[total][total];
	
	//rot90
 public	 int rot90 (char[][] s2,char[][] s3)
	{
		for( m=0;m<total;m++)
	     {l=0;

		   for(n=total-1;n>=0;n--)
		   {
//[B]line33[/B]		     s5[m][l]=s2[n][m]; [B]\\Exception in thread "main"                                  \\java.lang.ArrayIndexOutOfBoundsException: 0
	                                \\at trans.rot90(gift1.java:33)
	                                \\at gift1.main(gift1.java:208)[/B]

		      l++;
		   }
	     }
		if(s5==s3)
		 {
		  return 1;
		
		 }
		else
			return 0;
	}
	
	//rotaion180
	int rot180(char s2[][],char s3[][])
	{	
		for( m=total-1;m>=0;m--)
	   {     l=0;
	          k++;
		for(n=total-1;n>=0;n--)
		{
		 s5[k][l]=s2[m][n];
		  l++;
		 
		}

	   }
		
		if(s5==s3)
		{
		  return 2;
		
		}
		else
			return 0;
		
	
	
	}
	//roation270
	
	
	
	int rot270(char s2[][],char s3[][])
	{    k=-1;
		for( m=total-1;m>=0;m--)
	   {    k++;
		for(n=0;n<total;n++)
		{
		 s5[k][n]=s2[n][m];
		
		}

	   }
		
		if(s5==s3)
		{
		  return 3;
		
		}
		else
			return 0;
		
	
	}
	//horizontal
	int horz(char s2[][],char s3[][])
	{	for( m=0;m<total;m++)
	  {    l=0;

		for(n=total-1;n>=0;n--)
		{
		 s5[m][l]=s2[m][n];
		
		 l++;
		}

	  }
	
	if(s5==s3)
	   {
	     return 4;
	
	   }
	else
		return 0;
	
	
	}
	//combination
	int comb(char s2[][],char s3[][])
	{   for( m=0;m<total;m++)
	    {l=0;

		for(n=total-1;n>=0;n--)
		  {
		 s6[m][l]=s2[m][n];

		 l++;
		  }

	    }
	
	  no=rot90(s6,s3);
	  no=rot180(s6,s3);
	  no=rot270(s6,s3);
		
		if(no==1 | no==2 | no==3)
		   {
		     return 5;
		
		   }
		else
			return 0;
	
	
	}
	
}
class gift1 {
	public static void main(String args[]) throws IOException
	{
	    // Use BufferedReader rather than RandomAccessFile; it's much faster
	    BufferedReader f = new BufferedReader(new FileReader("gift1.in"));
	                                                  // input file name goes above
	    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("gift1.out")));
   
String s1=f.readLine();

int total=Integer.parseInt(s1);
char s2[][]=new char[total][total];
char s3[][]=new char[total][total];

int m,n,l=0,no=0;


for( m=0;m<total;m++)
   {
	s1=f.readLine();
	char s4[]=s1.toCharArray();
	
	for(n=0;n<total;n++)
	  { if(l<9)
		{
		  s2[m][n]=s4[n];
		  
		  l++;
		  if(l==9)
		  {  m=-1;
		     out.println("   ");
		     l++;
		  }
		}

	  else if(l>9 && l<=18)
		   {
			 s3[m][n]=s4[n];
			 l++;
			 
		   }  
		}
     }

trans r=new trans();
r.det(total);
if(s2==s3)
{ 
	no=6;
}




if(no==0)
{	
no=r.rot90(s2,s3);  [B]//line208[/B]
}
if(no==0)
 {	
  no=r.rot180(s2,s3);
  }
if(no==0)
{
  no=r.rot270(s2,s3);
}
if(no==0){  
	no=r.horz(s2,s3);
      }
if(no==0)
{
	no=r.comb(s2, s3);

}
if(no==0)
{
	no=7;
}   

    out.println(no);
  	out.close();
	}  
	

}

No compiler error!!!!!!!!!!!!!

Edited 5 Years Ago by __avd: Added [code] tags.

This article has been dead for over six months. Start a new discussion instead.