#include<iostream>
#include<math.h>
#define MAXNUM 6
using namespace std;
int SWAPI(int &,int &);
float computer(float,float,int);
int main()
{
int perm[MAXNUM];
int last,left,right,i,j;
cout<<"Pleaset input 4 number"<<endl;
for(i=0;i<MAXNUM;i++)//初始入perm[i]
{
perm[i]=i+1;
}
for(last=0;last>=0;)
{
for(j=0;j<MAXNUM;j++)//输出结果
{
cout<<perm[j]<<" ";
}
cout<<endl;
for(last=MAXNUM-2;last>=0&&perm[last]>perm[last+1];last--);//从后往前找perm[i]<perm[i+1]
if(last<0)//没找到
{
break;
}
for(j=MAXNUM-1;perm[last]>perm[j];j--);//从后往前找perm[i]<perm[j]
SWAPI(perm[last],perm[j]);//交换
for(left=last+1,right=MAXNUM-1;left<right;left++,right--)
{
SWAPI(perm[left],perm[right]);
}
}
cin>>i;
return 0;
}
int SWAPI(int &x,int &y)
{
int t;
t=x;
x=y;
y=t;
return 0;
}