看板 Grad-ProbAsk 關於我們 聯絡資訊
void swap(char *x,char *y) { char temp; temp=*x; *x=*y; *y=temp; } void perm(char *start,char *end) { char *cp; if(start==end){ printf("%s\n",start); } else { for(cp=start;cp<=end;cp++) { swap(cp,end); perm(start,end-1); swap(cp,end); } } } int main(int argc, _TCHAR* argv[]) { char str[]={'1','2','3','\0'}; perm(str,str+strlen(str)-1); system("pause"); return 0; } 程式大概是這樣 我用VS2008跑答案是對的 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.44.175.127
john19880902:感謝~我剛用DEV-C++跑也OK!^^ 01/21 01:36
w29697146:感謝大大把整個code打出來 我剛剛檢驗了一下可以過XD 01/21 17:48
metalalive:推! 01/22 02:11
fizz5566: 推! 12/27 10:09