using namespace std;
void swap(int& a, int& b) {int temp = a;a = b;b = temp;}
void permute(int array[], int start, int end) {if (start == end) {for (int i = 0; i <= end; i++) {cout << array[i] << " ";}cout << endl;} else {for (int i = start; i <= end; i++) {swap(array[start], array[i]);permute(array, start + 1, end);swap(array[start], array[i]);}}}
int main() {int array[] = {1, 2, 3, 4};permute(array, 0, 3);return 0;}
using namespace std;
void swap(int& a, int& b) {
int temp = a;
a = b;
b = temp;
}
void permute(int array[], int start, int end) {
if (start == end) {
for (int i = 0; i <= end; i++) {
cout << array[i] << " ";
}
cout << endl;
} else {
for (int i = start; i <= end; i++) {
swap(array[start], array[i]);
permute(array, start + 1, end);
swap(array[start], array[i]);
}
}
}
int main() {
int array[] = {1, 2, 3, 4};
permute(array, 0, 3);
return 0;
}