c++ stl全排列函数 next_permutation不香吗qwq

#include<cstdio> 
#include<algorithm>
using namespace std;
int n,a[9]= {1,2,3,4,5,6,7,8,9};
int main() {
    scanf("%d",&n);
    do {
        for (int i=0; i<n; i++) printf("%d ",a[i]);
        puts("");
    } while(next_permutation(a,a+n));
}