Complete IIT AIEEE ICSE ISC PMT help forum
This is a free help Forum for Indian Students.
Complete IIT AIEEE ICSE ISC PMT help forum

Complete help forum for students preparing for icse iit aieee cbse pmt and other related exams.Stay updated about all 2011 exams.
 
HomeHome  PortalPortal  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  India NewsIndia News  
Keywords
practical class maths result 10th Icse 2009 table programs java timetable board SYLLABUS Exam MODEL english PAPERS TEST sample time Results 2011 computer question CHEMISTRY 2008
Latest topics
» optical fibre????
Fri May 18, 2012 8:54 pm by mahnoorbloch

» physics............
Fri May 18, 2012 8:43 pm by mahnoorbloch

» magnetism...........chapter
Fri May 18, 2012 8:33 pm by mahnoorbloch

» ac generator
Fri May 18, 2012 7:46 pm by mahnoorbloch

» Great website for maths
Sun May 06, 2012 9:39 am by mahnoorbloch

» BlueJ prog
Tue Apr 24, 2012 11:53 am by arryaan

» GBTU SEE 2012 22 April
Sat Apr 21, 2012 11:17 am by shreya94

» GBTU SEE or UPTU SEE 2012 Expected cutoff marks
Sat Apr 21, 2012 11:16 am by shreya94

» GBTU SEE 2012 UPTU SEE 2012 Solutions Answer key discussion
Sat Apr 21, 2012 11:15 am by shreya94

Top posters
abhas
 
Anu..i luv icse...:)
 
G-7
 
siya
 
Candy
 
jOhNy
 
Apurva
 
WinRrule
 
ambili
 
saif
 



Search if you can't find it here

SPIRAL matrix Program using My logic

View previous topic View next topic Go down
AuthorMessage
saif
Active member
Active member



PostSubject: SPIRAL matrix Program using My logic Tue Feb 23, 2010 11:19 pm

7
1 2 3 4 5 6 7
24 25 26 27 28 29 8
23 40 41 42 43 30 9
22 39 48 49 44 31 10
21 38 47 46 45 32 11
20 37 36 35 34 33 12
19 18 17 16 15 14 13

But I am sure that it won't be asked tomorrow



import java.io.*;
class spiral
{

private static int arr[][];
private static int c=-1,r=0,count=0;
public static void main(String args[])throws IOException
{
BufferedReader obj =new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(obj.readLine());
arr=new int[n][n];
fill('R',n);

for(int i=n-1;i>=1;i--)
{
fill('D',i);
fill('L',i);
if(--i==0)break;
fill('U',i);
fill('R',i);
}

for(int i=0;i
Back to top Go down
View user profile
WinRrule
Active member
Active member



PostSubject: Re: SPIRAL matrix Program using My logic Fri Mar 12, 2010 4:00 pm

ur expectation was right..!
Back to top Go down
View user profile
RC
Active member
Active member



PostSubject: Re: SPIRAL matrix Program using My logic Sat Mar 13, 2010 10:24 am

class S1002
{
void main(int n)
{
int a[][]=new int[n][n];int c=1;
for (int i = n-1, j = 0; i > 0; i--, j++)
{
for (int k = j; k < i; k++) a[j][k]=c++;
for (int k = j; k < i; k++) a[k][i]=c++;
for (int k = i; k > j; k--) a[i][k]=c++;
for (int k = i; k > j; k--) a[k][j]=c++;
}
//special case for middle element if N is odd
if (n % 2 == 1) a[(n-1)/2][(n-1)/2]=c++;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
System.out.print(a[i][j]+" ");
System.out.println();}
}

}
Back to top Go down
View user profile

SPIRAL matrix Program using My logic

View previous topic View next topic Back to top
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Complete IIT AIEEE ICSE ISC PMT help forum :: ISC :: ISC 2010 [Class xii] :: Computer-