發表文章

目前顯示的是有「筆記」標籤的文章


~~ 記錄自己點點滴滴的學習歷程 ~~





C:遞迴 permutation -- 排列組合

圖片
程式碼 list = [a, b, c]; perm(list, 0, n-1); void perm () { int j, temp; if (i == n) { for (j=0; j<=n; j++) { printf("%c", list[j]); } printf(" "); } else { for (j=0; j<=n; j++) { swap(list[i], list[j], temp); perm(list[i], i+1, n); swap(list[i], list[j], temp); } } } 遞迴過程