Pagini recente » Cod sursa (job #2014993) | Cod sursa (job #2169062) | Cod sursa (job #276592) | Monitorul de evaluare | Cod sursa (job #389616)
Cod sursa(job #389616)
#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);
std::copy(stack.begin(), stack.end(), std::ostream_iterator<uint>(fout, " "));
fout << std::endl;
while(!stack.empty())
{
if(stack.back() < n)
stack.push_back(stack.back() + 1);
else
{
stack.pop_back();
stack.back()++;
}
std::copy(stack.begin(), stack.end(), std::ostream_iterator<uint>(fout, " "));
fout << std::endl;
}
fout.close();
fin.close();
return 0;
}