Occasionally opened the previous exercises, unconscious and want to knock once again, although some ideas are still so old-fashioned, but after all, is also a consolidation of knowledge.
First, the title: There are 1, 2, 3, 44 numbers, can make up how many different and no duplicate number of three digits? How much are they?
The specific idea is simple, is to take out a number, with the other three of any two non-repeating groups, and finally add up,
/*** Title: There are 1, 2, 3, 44 numbers, can make up how many different and no repetition of the number of three digits? How much are they? * Time: March 10, 2016 21:34:15 **/ Public classZushu { Public Static voidMain (string[] args) {intnum= 0,count=0; for(intI =1;i<5;i++){ for(intJ =1;j<5;j++){ for(intk=1;k<5;k++){ if(i!=j && i!=k && j!=k) {num= i*100+j*10+K; Count++; System.out.print (Num+" "); } }}} System.out.println (""); System.out.println ("Number is:" +count); }}
Printing results are:
123 124 132 134 142 143 213 214 231 234 241 243 312 314 321 324 341 342 412 413 421 423 431 432个数为:24
This idea is a more stupid way, for a lot of times, not too suitable, nested loops too much, I hope the great God has a good algorithm, a lot of corrections!
Java Algorithm Little knowledge Exercise