Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 13-10-2005, 06:53 AM   #1 (permalink)
Broken In
 
Join Date: Oct 2004
Posts: 162
Default a java problem


please tell how to implement this program in java

Q2.Magic Squares.An n*n matrix that is filled with the numbers 1,2,...,n*n is a
magic square if the sum of the elements in each row ,in each column,and in the
two diagonals is the same value . For example
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
Write a program that reads in n*n values from the keyboard and tests whether
they form a magic square when put into array form.You need to test three
features:
->Did the user enter n*n numbers for some n?
->Does each of the numbers 1,2...,n*n occur exactly once in the user input?
->When the no.s are put into a square , r the sums of the rows , columns and
diagonals equal to each other?
If the size of the input is a square,test whether all no.s between 1 and n are
present.Then compute the row , column, and diagonal sums.
shivi4 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 13-10-2005, 09:36 AM   #2 (permalink)
Human Spambot
 
Join Date: Nov 2004
Location: Madurai
Posts: 2,349
Default

task 1: is it necessary to use a termination character to stop the inputs or are u planning to ask user number of entries at the start? If latter, you can ask directly number of rows/columns and take that as n
task 2: i think you can use binary sort on a duplicate array and then check each number with the next in the list to ensure no two numbers are repeated.
task 3: this should be a no-brainer

Arun
sakumar79 is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by topgear
- by Charan

Advertisement




All times are GMT +5.5. The time now is 06:47 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2