answersLogoWhite

0

//Wondrous Square

import java.io.*;

class Wsq

{

public static void main(String args[])throws IOException

{

int n;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.print("enter input:");

n=Integer.parseInt(br.readLine());

int i,j;

int p[][]=new int[n][n];

System.out.print("Input The Elements:");

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

p[i][j]=Integer.parseInt(br.readLine());

}

}

int sum,sum1;

sum=sum1=0;

int f=0;

int com=(int)(1*n*(Math.pow(n,2)+1))/2;

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

sum=sum+p[i][j];

sum1=sum1+p[j][i];

}

if((sum!=com)(sum1!=com))

{

f=1;

}

sum=0;

sum1=0;

}

if(f==1)

{

System.out.println("Not A Wondrous Square:");

}

else

{

System.out.println("wondrous Square:");

}

if(f==0)

{

int g=0,k;

System.out.println("Prime No.\t Row \t Index:");

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

for(k=1;k<p[i][j];k++)

{

if(p[i][j]%k==0)

{

g++;

}

}

if(g==1)

{

System.out.println(p[i][j]+"\t"+i+"\t"+j);

}

g=0;

}

}

}

}

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you solve this program wap to print sum of a digit of an inputed number?

wap to print all the arnstrong no. between 100&amp;1000


How do you make mobile project documentation?

Mobile project doc ? its not clear which kind docs required , bcoz mobile diff client are there BREW ,WAP,J2me Brew (MIxed the java and c tech) WAP fully java , j2me .. adv, java .


WAP to print esquare 10 natural number?

yo yo as


WAP to show the difference between a variable and static variable?

difference between constant and static variables in java


WAP to initialize the character and print with it upper case lower case or special case in java?

public static void main(String[] args) { char val = 'a'; String vals = val + ""; System.out.println("Lower Case: " + vals.toLowerCase()); System.out.println("Upper Case: " + vals.toUpperCase()); }


WAP in java to take alphabet and print ascii value for it?

Remember that chars in Java are just a special version of ints. Cast the char as an int and you get the Unicode value for it. Fortunately, the group of characters including letters and numbers have the same value in both encoding systems. for (char letter = 'a'; letter &lt;= 'z'; ++letter) { System.out.println("ASCII of " + letter + " = " + (int) letter); }


WAP to print even numbers upto 20 and find the total in Q-Basic?

cls total=0 for i=0 to 20 step -2 total = total+i print i ; next i print "total is " total end send by tripti


Wap to take a number from the user and print its square if the number is even otherwise incase of odd number print its cube?

#include&lt;iostream&gt; using namespace std; int main(void) { int a; int b; { cout &lt;&lt; "Please enter a number: "; cin &gt;&gt; a; b = a%2 == 0 ? a*a : a*a*a; cout &lt;&lt; "The result is: " &lt;&lt; b &lt;&lt; endl; } return 0; } - - - //Alternative #include&lt;iostream&gt; #include&lt;cmath&gt;


What are some of the top wap sites?

Some of the top sites are Prodigits, Phoneky, Free Android Games, Free Java Games, Twilight Zone, DownloadWAP, Free MP3 Ringtones, Free Java Apps, MobiGroups, Free Wallpapers, Free Mobile Screensavers.


WAP to print in c program in 0 10 010kzvcs?

#include &lt;stdio.h&gt; int main (void) { puts ("in 0 10 010kzvcs"); return 0; }


What is a wap code?

Samsung s5233 wap code


How do i get wap on my phone?

To get wap on your mobile phone, simply get in touch with your service provider. The provider will give you instructions on how to get wap.