fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. int a[n];
  9. for (int i = 0; i < n; i++) cin >> a[i];
  10. next_permutation(a, a+n);
  11. for (int i = 0; i < n; i++) cout << a[i] << " ";
  12. return 0;
  13. }
Success #stdin #stdout 0s 4480KB
stdin
1
1
stdout
1