#include"iostream.h" int str[5]={0,1,2,3,4}; void swap(int &a,int &b); void perm(int list[5],int k,int m) { if(k==m) { for(int i=0;i<m;i++) cout<<list[i]; cout<<endl; } else for(int i=k;i<m;i++) { swap(list[k],list[i]); perm(list,k+1,m); swap(list[k],list[i]); } } void swap(int &a,int &b) { int t=a;a=b,b=t; } void main() { perm(str,0,3); } 運行結果: 012 021 102 120 210 201 Press any key to continue
求排列
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
[oeasy]python019_ 如何在github倉庫中進入目錄_找到程序代碼_找到代碼
繼續運行 🥋 回憶上次內容 上上次 真寫了 萬行 代碼 這 萬行 代碼 都是寫在 明面 上的 這次 使用git命令 下載了 github上面的倉庫
原創
2024-05-30 00:35:24
java將list結果分成3份執行 原創
文文1
2024-05-16 02:09:55
Java中的List
原創
2024-05-01 21:31:27
重磅新品發佈!雲耀數據庫HRDS,享受輕量級的極致體驗
原創
2024-04-23 22:32:33
Java中List、Set、Map的區別
原創
2024-04-22 21:31:29
數據結構筆記淺記(八)列表
原創
2024-04-18 23:39:19
基於Redis實現基本搶紅包算法
原創
2024-04-17 11:18:19
O2OA開發平臺如何查看數據表結構?
原創
2024-04-12 22:25:42
數據結構筆記淺記(九)存儲設備
原創
2024-04-08 23:38:13
百川倉配切量接口成長史
原創
2024-03-28 00:34:45
得嘞,分頁插件PageHelper返回記錄總數total竟然出錯了!
原創
2024-03-21 00:14:01
vue3使用axios返回json用v-for遍歷失效,標籤不渲染
文文1
2024-02-28 02:34:12
【幻獸帕魯】專用服務器攻略來啦!一鍵部署,5s開服
原創
2024-02-07 11:02:37