6 solutions

  • 0
    @ 2026-2-23 20:48:13
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int a[5]={0,1,2,3,4}; //初始化 
    	int n=4;
    	do{
    		for(int i=1;i<=n;i++)
    		{
    			cout<<a[i]<<" "; 
    		}
    		cout<<endl;
    	}while(next_permutation(a+1,a+n+1)); //得到a[1]到a[n]的下一个排列 
    	return 0;
    }
    
    

    Information

    ID
    191
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    86
    Accepted
    22
    Uploaded By