| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
递推足够过了。。。#include <iostream>
using namespace std;
class P{
public :
int pos[6];
int number[14];
int n;
P(){};
void init(){
for(int i = 0 ; i < 6 ; i ++ ){
pos[i] = i;
}
}
friend istream & operator >> (istream &in,P &op){
for(int i = 0 ; i < op.n ; i ++ ){
cin >> op.number[i];
}
return in;
}
friend ostream & operator << (ostream &out,P &op){
for(int i = 0 ; i < 5 ; i ++ ){
out << op.number[op.pos[i]] << " ";
}
out << op.number[op.pos[5]] << endl;
return out;
}
};
void cp(P &p){
cout << p;
while(p.pos[0] != p.n - 6){
int pp = 0;
for(int i = 5 ; i >= 0 ; i -- ){
if(p.pos[i] != p.n - 6 + i){
pp = i;
break;
}
}
int k = p.pos[pp] + 1;
for(int i = pp ; i <= 5 ; i ++ ){
p.pos[i] = k ++;
}
if(p.pos[5] == p.n)
continue;
cout << p;
}
cout << endl;
}
int main(){
P p;
while(scanf("%d",&p.n) && p.n){
p.init();
cin >> p;
cp(p);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator