剑指offer--字符串排列

来源:互联网 发布:java中int的范围 编辑:程序博客网 时间:2024/06/05 10:43



#include<iostream>using namespace std;void Permutation(char* pstr, char* pbegin){if (*pbegin == '\0')printf("%s\n", pstr);else{for (char* pch = pbegin; *pch != '\0'; ++pch){char temp = *pch;*pch = *pbegin;*pbegin = temp;Permutation(pstr, pbegin + 1);temp = *pch;*pch = *pbegin;*pbegin = temp;}}}void Permutation(char* pstr){if (pstr == NULL)return;Permutation(pstr, pstr);}int main(){char str[] = "abc";Permutation(str);system("pause");return 0;}


1 0
原创粉丝点击