Title Requirements:
1. Must contain 122345 of these six numbers
2. The third digit in the number (hundred) cannot be 4
3. Output 6 digits of all the above two conditions
The code is as follows:
StaticString[] Numberstrings = {"1", "2", "3", "4", "5"}; Public Static voidMain (string[] args) { for(inti=122345;i<999999;i++) {Onetof (i+""); } } Public Static voidOnetof (FinalString number) { for(String n:numberstrings) {if(Number.indexof (n) <0) return; } if(Number.indexof ("4") ==3) return; if(Number.lastindexof ("2") ==number.indexof ("2"))) return; if("Number.indexof") >0 | | number.indexof ("(") > 0) return; SYSTEM.OUT.PRINTLN (number); }
So, the question is, if it's not a 6-digit number, but a 7-bit, or a lot of other bits, you need to change it:
if (Number.indexof ("4") = = Number.length ()-3 ) return;
That's it.
But this method feel inefficient, if there is an idea, welcome message ....
122345 arrange randomly to find the number that satisfies the condition