Lotto


#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

const int maxn = 1005;
int num[ maxn ];

int main(){
	int n;
	while( cin >> n ){
		if( !n )
			break;
		for( int i = 0; i < n; ++i ){
			cin >> num[ i ];
		}
		for( int i = 0; i < n; ++i ){
			for( int j = i + 1; j < n; ++j ){
				for( int k = j + 1; k < n; ++k ){
					for( int x = k + 1; x < n; ++x ){
						for( int y = x + 1; y < n; ++y ){
							for( int z = y + 1; z < n; ++z ){
								cout << num[ i ] << " " << num[ j ] << " " << num[ k ] << " " << num[ x ] << " " << num[ y ] << " " << num[ z ] << endl;
							}
						}
					}
				}
			}
		}
		cout << endl;
	}	
return 0;
}



#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

const int maxn = 1005;
int num[ maxn ], temp[ maxn ], n;

void dfs( int start, int end ){
	if( start > 6 ){
		for( int i = 1; i <= 5; ++i ){
			cout << num[ i ] << " "; 
		}
		cout << num[ 6 ] << endl;
	}
	else{
		for( int i = end; i < n - ( 6 - start ) + 1; ++i ){
			num[ start ] = temp[ i ];
			dfs( start + 1, i + 1 );
		}
	}
}

int main(){
	while( cin >> n ){
		if( !n )
			break;
		for( int i = 1; i <= n; ++i ){
			cin >> temp[ i ];
		}
		dfs( 1, 1 );
		cout << endl;
	}
return 0;
}


Lotto

上一篇:Smallest Difference(贪心)


下一篇:ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题