leetcode之Permutations问题


#include
#include
using namespace std;
class Solution {
public:
	vector> permute(vector& nums);
};
int fractorial(int N)
{
	return N == 1 || N == 0 ? 1 : N*fractorial(N - 1);
}
void next_index(vector &index, vector &bounds)
{
	int i = index.size() - 1;
	while (i >= 0)
	{
		if (index[i]> Solution::permute(vector& nums) {
	int N = nums.size();
	vector> res;
	vector ori_nums = nums;
	vector index(N, 0);
	vector tmp = nums;
	vector bounds(N);
	for (int i = 0; i> &nums)
{
	for (vector>::iterator iter1 = nums.begin(); iter1 != nums.end(); ++iter1)
	{
		for (vector ::iterator iter2 = (*iter1).begin(); iter2 != (*iter1).end(); ++iter2)
		{
			cout << *iter2 << " ";
		}
		cout << endl;
	}
}
int main()
{
	Solution s;
	int arr[] = { 1, 3, 2 };
	vector nums;
	for (int i = 0; i < sizeof(arr) / sizeof(int); ++i)
	{
		nums.push_back(arr[i]);
	}
	vector> res = s.permute(nums);
	print_vector(res);
	system("pause");
}


你可能感兴趣的:(C++基础)