Source: Internet
Author: User

Label:

1 ImportJava.util.HashMap;2 ImportJava.util.Map;3 ImportJava.util.Map.Entry;4 //in a positive integer less than 99999, find the number that meets the following criteria, which is both a full square number,5 //another two digits are the same, such as: 144,676. 6 Public classWQS {7 8 //Total Square Number9 Public Static BooleanIswqs (intN) {Ten inti; One Doubledn=math.sqrt (n); A if(Dn-(int) dn==0) - return true; - return false; the } - //Judging only two bits of the same - Public Static BooleanTwosame (intN) { -map<integer,integer>map=NewHashmap<integer,integer>(); + while(n>0){ - intN1=n%10; + //System.out.print (N1); A if(Map.containskey (N1)) at { - intVal=Map.get (N1); -Map.put (n1,val+1); - } - Else -Map.put (N1, 1); inN=n/10; - } to //System.out.print (map); + for(entry<integer,integer>En:map.entrySet ()) - { the if(En.getvalue () ==2){ * return true; $ }Panax Notoginseng } - the return false; + } A the Public Static voidMain (string[] args) { + inti; - for(i=2;i<99999;i++){ $ if(Twosame (i) &&Iswqs (i)) { $System.out.println (i+ ""); - } - } the } - Wuyi}

Java. In a positive integer less than 99999, find the number that meets the following criteria, which is both full squared and two digits the same, for example: 144,676.

Related Article