將1到N的N個自然數排成一列,共有1*2*3……*N種不同的排列方法,如N=3時,有6種排列方案,分別為123,132,213,231,312,321.試編程序輸出1到N的全部排列,假設N<10.
為了設計出由計算機輸出1到N的全部排列程序,就必須尋找不同排列之間的規律.通過觀察N=5(參見本例的運行結果)的排列情況,可以發現,如果把每個排列看作一個自然數,
則所有排列對應的數是按從小到大的順序排列
標簽:
123
132
213
231
上傳時間:
2013-12-24
上傳用戶:lvzhr
Core Java 2 Volume I - Fundamentals, Seventh Edition
Completely revised and up-to-date coverage of
Generic programming, restrictions and limitations, type bounds, wilcard types, and generic reflection
Swing GUI development, including input validation and other enhancements
Exception handling and debugging, including chained exceptions, stack frames, assertions, and logging
Streams and files, the new I/O API, memory-mapped files, file locking, and character set encoders/decoders
Regular expressions using the powerful java.util.regex package
Inner classes, reflection, and dynamic proxies
Application packaging and the Preferences API
標簽:
Fundamentals
Completely
up-to-date
coverage
上傳時間:
2016-01-02
上傳用戶:標點符號