ritu.jnu08
BAN USER
Repsandrafdenn, Associate at CareerCup
Je suis développeur web dans une société de Wild Oats Markets, j'adore faire du shopping et j'ai une ...
Repsonjamramos45, Graphics Programmer at CGI-AMS
I am a strong writer with a passion for story-telling who has extensive experience of writing literary compositions, articles, reports ...
Reparlinenwalters, Software Analyst at ASAPInfosystemsPvtLtd
I Performed extensive web research to collect pertinent data and gather images related to the assigned articleIts act of writing ...
Reppaulinedsisk, Testing / Quality Assurance at Cloudmere, Inc.
I want to become a successful professional in a highly competitive technological world where performance is rewarded with exciting new ...
Repjessicajbunting, Aghori Mahakal Tantrik at ABC TECH SUPPORT
Hi I am Jessica, from Houston USA. I am working as a manager in Incredible Universe company. I enjoy additional ...
Repbrandysolsen, Area Sales Manager at AMD
I am a Social butterflies who enjoy travel.Have fun doing this job and project an atmosphere that reflects Amazon ...
public class SpiralPattern {
- ritu.jnu08 June 11, 2016public static void main(String[] args) {
int arr[][]={{1, 2, 3, 4, 5, 6},
{7, 8, 9, 10, 11, 12},
{13, 14, 15, 16, 17, 18},
{19, 20, 21, 22, 23, 24},
{25, 26, 27, 28, 29, 30},
{31, 32, 33, 34, 35, 36}};
int startRow = 0;
int col = arr[0].length;
int row =arr.length;
SpiralPrint(arr,startRow,col, row, 0);
}
private static void SpiralPrint(int[][] arr, int startRow, int col , int row, int loop) {
int i,j ,k, l;
//print first row
if(startRow==arr.length/2)
{
return;
}
for(j=0+loop;j<col-1;j++)
{
System.out.print(arr[startRow][j]+" ");
}
// print last column
for( k=0+loop;k<row-1;k++)
{
System.out.print(arr[k][j]+" ");
}
//print last row
for(l=col-1;l>0+loop;l--)
{
System.out.print(arr[k][l]+" ");
}
//print first column
for(i=row-1;i>0+loop;i--)
{
System.out.print(arr[i][l]+" ");
}
SpiralPrint(arr,startRow+1,col-1, row-1, loop+1);
}
}