Pagini recente » Profil Dobricean_Ioan | monthly-2014/runda-2/clasament | Cod sursa (job #971256) | preoji_cl11_12_lspvs | Cod sursa (job #389628)
Cod sursa(job #389628)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
typedef unsigned char byte;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ulonglong;
#define NDEBUG
#ifdef NDEBUG
#define dbg 0 && (*((ostream *) 0))
#else
#define dbg clog
#endif
int main(int argc, char * argv[])
{
const char * inFile = "submultimi.in";
const char * outFile = "submultimi.out";
ifstream fin(inFile);
ofstream fout(outFile);
#ifndef NDEBUG
if(!fin || !fout)
{
cerr << "Error opening one of \"" << inFile << "\" or \"" << outFile << "\"" << endl;
return -1;
}
#endif
ulong n;
fin >> n;
std::vector<uint> stack;
stack.reserve(32);
stack.push_back(1);
for(int i = 0; i < stack.size(); i++)
{
fout << stack[i] << " ";
}
fout << "\n";
while(!stack.empty())
{
if(stack.back() < n)
{
stack.push_back(stack.back() + 1);
}
else
{
stack.pop_back();
stack.back()++;
}
for(int i = 0; i < stack.size(); i++)
{
fout << stack[i] << " ";
}
fout << "\n";
}
fout.close();
fin.close();
return 0;
}