33,007
社区成员
发帖
与我相关
我的任务
分享
#include <vector>
#include <iostream>
using namespace std;
struct Point
{
int x;
int y;
};
typedef vector<Point> PVtr;
typedef vector<Point>::iterator PIter;
void find(const int sizex,const int sizey,PVtr pvtr,const int max)
{
if (sizex == max - 1 && sizey == 0)
{
cout<<"out:"<<endl;
cout<<0<<" "<<max - 1<<endl;
for (PIter i = pvtr.begin();i != pvtr.end();++i)
{
cout<<(*i).x<<" "<<(*i).y<<endl;
}
cout<<endl;
return;
}
if (sizex < max - 1)
{
Point p = {sizex + 1,sizey};
PVtr tem = pvtr;
tem.push_back(p);
find(sizex + 1,sizey,tem,max);
}
if (sizey > 0)
{
Point p = {sizex,sizey - 1};
PVtr tem = pvtr;
tem.push_back(p);
find(sizex,sizey - 1,tem,max);
}
}
int main()
{
PVtr pvtr;
find(0,2,pvtr,3);
return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
char dir[2]={'^','>'};
int n;
cin>>n;
int *L=new int[2*n];
for( int i=0; i<2*n; ++i )
L[i]=i<n? 0 : 1;
do{
for( int i=0; i<2*n; ++i )
cout<<dir[L[i]]<<" ";
cout<<endl;
}while( next_permutation( L, L+2*n ) );
delete []L;
return 0;
}