-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCTDL005.cpp
48 lines (44 loc) · 829 Bytes
/
SCTDL005.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @file SCTDL005.cpp
* @author long ([email protected])
* @brief C++ program to display all permutations
* of an array using STL in C++
* @version 0.1
* @date 2023-02-27
*
* @copyright Copyright (c) 2023
*
*/
#include <bits/stdc++.h>
using namespace std;
// Function to display the array
void display(int a[], int n)
{
for (int i = 0; i < n; i++) {
cout << a[i];
}
cout << " ";
}
// Function to find the permutations
void findPermutations(int a[], int n)
{
do {
display(a, n);
} while (next_permutation(a, a + n));
}
int main()
{
int t;
cin >> t;
while(t--) {
int n, arr[11];
cin >> n;
for(int i=0; i < n; i++)
{
arr[i] = i+1;
}
findPermutations(arr, n);
cout << endl;
}
return 0;
}