Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:递推足够过了。。。

Posted by tanjing at 2010-09-16 00:37:04 on Problem 2245
In Reply To:递推足够过了。。。 Posted by:dinysirius at 2009-04-16 23:56:31
> #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;
> }
顶个,从我搞ACM开始很少写这样的类了。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator