Pagini recente » Cod sursa (job #1862329) | Cod sursa (job #1309116) | Cod sursa (job #749193) | Cod sursa (job #1169707) | Cod sursa (job #389646)
Cod sursa(job #389646)
#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.push_back(1);
for(std::vector<uint>::size_type 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();
if(!stack.empty())
stack.back()++;
}
for(std::vector<uint>::size_type i = 0; i < stack.size(); i++)
{
fout << stack[i] << " ";
}
fout << "\n";
}
fout.close();
fin.close();
return 0;
}