cpython3


私信TA

用户名:smartZhou

访问量:71518

签 名:

等  级
排  名 36
经  验 12916
参赛次数 1
文章发表 99
年  龄 0
在职情况 学生
学  校
专  业 计算机科学与技术

  自我简介:

TA的其他文章

解题思路:
C内部自带全排列函数:

next_permutation(arr,arr+size);    求下一个全排列

prev_permutation(arr,arr+size);    求上一个全排列

The return value which is a bool type.

The global varible g_count  set value 1; 

 

注意事项:

参考代码:

#include <iostream>
#include <algorithm>
using namespace std;
int g_count = 1;
int main()
{

	int index;  cin >> index;
	int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
	do
	{
		if (index == g_count)
		{
			for (int i = 0; i<10; i++)
			{
				cout << arr[i];
			}
			cout << endl;  break;
		}
		g_count++;
	} while (next_permutation(arr, arr+10));
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区