首页 > 其他 > 详细

Lotto

时间:2014-01-29 16:25:45      阅读:607      评论:0      收藏:0      [点我收藏+]


#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

原文:http://blog.csdn.net/bo_jwolf/article/details/18851445

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!