package Chapter 2;
//Output all 4-digit perfect square numbers in the form of aabb
public class Perfect square number 7744 problem{
public static void main(String[] args) {
// TODO Auto-generated method stub //option1 // Find its square root to see if it is an integer, that is, use an int variable m to store the rounded integer of sqrt(n) and then judge whether m*m is equal to n for(int a=1;a<=9;a++) { for( int b=0;b<=9;b++) { int n=a*1000+a*100+b*10+b; //Because there may be errors in the operation of floating point numbers //Add 0.5 rounding int m= (int)(Math.sqrt(n)+0.5); if(m*m==n) { System.out.println(n+" "); } } } //option2 //enumeration for(int x =1;x*x<=9999;x++) { int n=x*x;
if(n/1000==(n%1000)/100&&n%10==(n%100)/10&&n>1000)
{
System.out.println(n);
}
}
}
}
//Output all 4-digit perfect square numbers in the form of aabb
public class Perfect square number 7744 problem{
public static void main(String[] args) {
// TODO Auto-generated method stub //option1 // Find its square root to see if it is an integer, that is, use an int variable m to store the rounded integer of sqrt(n) and then judge whether m*m is equal to n for(int a=1;a<=9;a++) { for( int b=0;b<=9;b++) { int n=a*1000+a*100+b*10+b; //Because there may be errors in the operation of floating point numbers //Add 0.5 rounding int m= (int)(Math.sqrt(n)+0.5); if(m*m==n) { System.out.println(n+" "); } } } //option2 //enumeration for(int x =1;x*x<=9999;x++) { int n=x*x;
if(n/1000==(n%1000)/100&&n%10==(n%100)/10&&n>1000)
{
System.out.println(n);
}
}
}
}