注册 登录
编程论坛 C++教室

就是怎么理解递归 for循环 递归

神秘黑夜 发布于 2016-04-09 17:03, 3383 次点击
就是怎么理解递归 for循环 递归

void swap(int &a, int &b)
{
    int temp;
    temp = a;
    a = b;
    b = temp;
}
//递归函数
void fullPermutation(int * c, int start, int end, int number) {
    if (start >= end) {
        for (int i = 0; i<number; i++) {
            cout << c[i];
        }
        cout << endl;
        total++;
    }
    else
    {
        for (int i = start; i <= end; i++)
        {
            swap(c[start], c[i]);
            fullPermutation(c, start + 1, end, number);
            swap(c[start], c[i]);
        }
    }
不理解怎么,,,
0 回复
1