Cod sursa(job #376276)

Utilizator alexandru92alexandru alexandru92 Data 21 decembrie 2009 10:37:35
Problema Submultimi Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.47 kb
#include <fstream>
#define check_bit( x, poz ) ( (x) & (1<<(poz) ) ) //check if bit poz is set

/*
 *
 */
using namespace std;
int main()
{bool ok; 
 int n, i=1, j;
    ifstream in("submultimi.in");
	in>>n;
	ofstream out("submultimi.out");
	do //stop when we have the 111111....1 configuration
	{ok=false;
	    for( j=1; j <= n; ++j )
		   if( check_bit( i, j-1 ) )
		      out<<j<<' ';
		   else ok=true;
		out<<'\n';
		++i;
	}while( ok );
	return 0;
}