沐里纷纷


私信TA

用户名:Epoch

访问量:62733

签 名:

我不会算法

等  级
排  名 37
经  验 12807
参赛次数 1
文章发表 172
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

不会算法

解题思路:

啥情况??

捕获.JPG
注意事项:

参考代码:

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> arr;

int main(int argc, char** argv)
{
 int n = 0;
 cin >> n;
 int index = 0;
 cin >> index;
 for (int i = 0;i < n;i++)
 {
  int temp;
  cin >> temp;
  arr.push_back(temp);
 }
 
 int i = 1;
 while(next_permutation(arr.begin(),arr.end()))
 {
  if (i == index)
   break;
  i += 1;
 }
 
 for (vector<int>::iterator it = arr.begin();it < arr.end();it++)
  cout << *it << " ";
 
	return 0;
}


 

0.0分

2 人评分

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

编程语言转换

万能编程问答

代码解释器

  评论区