what about this pattern: 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 without matrix in java

what about this pattern: without matrix in  java 

1 2 3 4  
8 7 6 5  
9 10 11 12  
16 15 14 13

class pattern

    static void printPattern(int n)
    {
int count = 1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i%2!=0)
{
System.out.print(count++);
}
else
{
System.out.print(count--);
}
}
if(i%2!=0)
{
count = count+3;
}
else
{
count = count+5;
}
System.out.println();
}   
}
    public static void main(String[] args) 
    {
        printPattern(4);      
    }

}



Make Money