解题思路:
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 人评分
A+B for Input-Output Practice (III) (C语言代码)浏览:570 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:1233 |
WU-printf基础练习2 (C++代码)浏览:2001 |
数列问题 (C语言代码)浏览:1019 |
整除的尾数 (C语言代码)浏览:809 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:518 |
简单的a+b (C语言代码)浏览:635 |
1074(纳闷了,答案错误,求指教)浏览:362 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:426 |
C语言程序设计教程(第三版)课后习题7.2 (C++代码)浏览:426 |