Keywords:
| Palindrome number Loop Condition statement |
2 |
Topic:
Workaround:
1 PackageCom.algorithm.java.blueBirdge;2 3 ImportJava.util.Scanner;4 5 Public classPaliindrome2 {6 Public Static voidMain (string[] args) {7Scanner Read =NewScanner (system.in);8 intsum =read.nextint ();9 //int sum=0;Ten for(inti=10000;i<=999999;i++){ One if(i>=10000 && i<=99999) { A //Digit - intGewei5=i% 10; - //10 Guests the intshiwei5= (i% 100)/10; - //Hundred - intbaiwei5= (i/100)%10; - //thousand + intqianwei5= (i/1000)% 10; - //million-bit + intwanwei5=i/10000; A //output such a five-digit number at if(gewei5== wanwei5 && (shiwei5) = = (QIANWEI5) && (gewei5+shiwei5+baiwei5+qianwei5+wanwei5==sum))) { - //if () { - System.out.println (i); - //} - - } in } - to //output such a six-digit 999 999 + Else{ - //Digit the intGewei6=i% 10; * //10 Guests $ intshiwei6= (i% 100)/10;Panax Notoginseng //Hundred - intbaiwei6= (i%1000)/100; the //thousand + intqianwei6= (i/1000)%10; A //million-bit the intwanwei6= (i/10000)% 10; + //100,000 guests - intshiwanwei6=i/100000; $ $ if(Gewei6 = = Shiwanwei6 && ((shiwei6) = = (Wanwei6)) && (baiwei6) ==qianwei6) && (gewei6+shiwei6+ baiwei6+qianwei6+wanwei6+shiwanwei6==sum)) { - //if () { - System.out.println (i); the //} - Wuyi } the } - } Wu } -}
Java Blue Bridge Cup--basic exercise (7) Special palindrome number