Cod sursa(job #3200082)

Utilizator andrei_botorogeanuBotorogeanu Andrei andrei_botorogeanu Data 3 februarie 2024 14:38:59
Problema Submultimi Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include<iostream>
#include<vector>
using namespace std;
vector<int> stiva;

int main()
{
	int n = 3;
	//cout<<"Generare submultimi: \n";
	stiva.push_back(1);
	while( !stiva.empty() ) {
	
		for(unsigned int i = 0; i<stiva.size(); ++i)
			cout<<stiva[i]<<" ";
		cout<<"\n";
		if( stiva.back() < n ) 
			stiva.push_back( stiva.back() + 1 );
		else {
			stiva.pop_back();
			if( !stiva.empty() )
				stiva.back()++;
		}
//		display();
	}
}