STL test question

int main() {
int T, N;
std::cin>>T;
while(T>0){
int a[N];
std::cin>>N;
for(int i=0; i<N; i++){
std::cin>>a[i];
}

	std::next_permutation(a,a+N);

	for(int i=0; i<N; i++){
		std::cout<<a[i]<<" ";
	}
	T=T-1;
	if(T>0){
		std::cout<<std::endl;
	}
}

return 0;

}

Here is my code, where I am missing. Plz help. Thanks

things you have to change

  1. int a[1000];
    make array of finite size (N contains garbage initially)
  2. #include < algorithm >
    include this header file it contains the function next_permutation()

NOTE
not need to use std:: every time instead of this just write one line
using namespace std;

Modified Code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.