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
This is a free help Forum for Indian Students.
Complete IIT AIEEE ICSE ISC PMT help forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
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  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  India NewsIndia News  
Keywords
graph papers computer question 2006 prelim 2009 SELECT 2007 UNION YEAR physics ICSE 2004 science RESULT CLASS paper CASE 2010
Latest topics
» Nitration of aniline - IIT JEE 2018 Advanced - solved
Magic Square(odd order) EmptyFri Jun 08, 2018 2:34 am by adianadiadi

» Diamagnetic - Paramagnetic - Ni(CO)4, [Ni(CN)4]2- and [NiCl4
Magic Square(odd order) EmptyFri Apr 06, 2018 1:05 am by adianadiadi

» IIT JEE chemistry solved interactive question paper
Magic Square(odd order) EmptySun Oct 29, 2017 12:11 pm by adianadiadi

» IIT JEE 2015 SOLVED QUESTION PAPER
Magic Square(odd order) EmptyWed Oct 19, 2016 1:44 pm by adianadiadi

» IIT JEE chemistry solved questions
Magic Square(odd order) EmptySat Jul 18, 2015 6:15 pm by adianadiadi

» General Description of Chinese Market for Foaming Agent ADC
Magic Square(odd order) EmptyFri May 09, 2014 2:09 pm by happybaicaitou

» How to get Lowest Cost MBBS Admission?
Magic Square(odd order) EmptyMon Feb 24, 2014 6:39 pm by MENTOR 2014

»  girl boy vashikaran specialist agori baba ji +91-9461165
Magic Square(odd order) EmptyTue Jan 21, 2014 6:00 pm by krshastri

»  STRONG LOST LOVE SPELL +91-9461165176
Magic Square(odd order) EmptyTue Jan 21, 2014 6:00 pm by krshastri

Top posters
abhas
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
Anu..i luv icse...:)
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
G-7
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
siya
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
Candy
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
jOhNy
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
Apurva
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
WinRrule
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
ambili
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 
saif
Magic Square(odd order) Vote_lcapMagic Square(odd order) Voting_barMagic Square(odd order) Vote_rcap 



Search if you can't find it here

Magic Square(odd order)

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



Magic Square(odd order) Vide
PostSubject: Magic Square(odd order) Magic Square(odd order) EmptyWed Feb 24, 2010 2:43 am

Magic Square odd order:[code]import java.io.*;
public class MagicSquare {
public static void main(String args[]) throws IOException{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter (odd) size of Magic Square:");
int n=Integer.parseInt(in.readLine());
int a[][]= new int[n][n];
int i=0,j= ((n+1)/2)-1 ;
a[i][j]=1;
int counter=1;
while(counter< n*n){
int itemp=i, jtemp=j;
if (itemp==0) itemp=n-1; else itemp--;
if (jtemp==n-1) jtemp=0; else jtemp++;
if (a[itemp][jtemp]!=0) { itemp=(itemp+2)%n ; jtemp=j;}
a[itemp][jtemp]=++counter;
i=itemp; j=jtemp;
}
for(int y=0; y
Back to top Go down
sa12
Active member
Active member



Magic Square(odd order) Vide
PostSubject: Re: Magic Square(odd order) Magic Square(odd order) EmptyWed Feb 24, 2010 2:44 am

I don't know why posts are cut but aftr y=0
for(int y=0; y<n; y++){
for(int z=0; z<n ;z++){
System.out.printf("%2d",a[y][z]); System.out.print(" ");
}
System.out.println();
}

}
}
Back to top Go down
saif
Active member
Active member



Magic Square(odd order) Vide
PostSubject: Re: Magic Square(odd order) Magic Square(odd order) EmptyWed Feb 24, 2010 3:02 am

import java.io.*;
public class MagicSquare {
public static void main(String args[]) throws IOException{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter (odd) size of Magic Square:");
int n=Integer.parseInt(in.readLine());
int a[][]= new int[n][n];
int i=0,j= ((n+1)/2)-1 ;
a[i][j]=1;
int counter=1;
while(counter< n*n){
int itemp=i, jtemp=j;
if (itemp==0) itemp=n-1; else itemp--;
if (jtemp==n-1) jtemp=0; else jtemp++;
if (a[itemp][jtemp]!=0) { itemp=(itemp+2)%n ; jtemp=j;}
a[itemp][jtemp]=++counter;
i=itemp; j=jtemp;
}
for(int y=0; y<n; y++){
for(int z=0; z<n ;z++){
System.out.printf("%2d",a[y][z]); System.out.print(" ");
}
System.out.println();
}

}
}


joined ur post WOW nice to see that i am not the only one who is awake till 1:30 today

Best of luck

I just made a prog. to generate truth table for three variable expression of type a.b+b.c+c.a+a.b.c+ .....
(single variable not allowed in expression)(input should be in ablove format only)
Back to top Go down
sa12
Active member
Active member



Magic Square(odd order) Vide
PostSubject: Re: Magic Square(odd order) Magic Square(odd order) EmptyWed Feb 24, 2010 3:06 am

I just started studying at 12:20. Didn't want to get into this situation but got into it nonethe less. Smile Note the System.out.printf in my program. The matrix that is printed is properly formatted.Anagrams via Recursion (though this will not come):</br>import java.io.*;
public class Anagrams {
public static void main(String args[])throws IOException {
BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a word:");
String word=in.readLine();
System.out.println("The anagrams of the word are:");
printAnagrams("",word);
}
public static void printAnagrams(String prefix,String word){
if(word.length()<=1) System.out.println(prefix+word);
else {
for (int i=0;i<word.length();i++){
String current=word.substring(i,i+1);
String before=word.substring(0,i);
String after=word.substring(i+1);
printAnagrams(prefix+current,before+after);
}
}
}
}
Back to top Go down
Sponsored content




Magic Square(odd order) Vide
PostSubject: Re: Magic Square(odd order) Magic Square(odd order) Empty

Back to top Go down

Magic Square(odd order)

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-