Pagini recente » Cod sursa (job #790612) | Cod sursa (job #1708174) | Cod sursa (job #3250269) | Cod sursa (job #1732677) | Cod sursa (job #2680575)
//
// main.cpp
// submultimi
//
// Created by Eusebiu Rares on 03.12.2020.
//
#include <iostream>
#include <fstream>
class OutoutParsing {
public:
OutoutParsing() {} ;
OutoutParsing(const char * file_name) {
output_file.open(file_name, std::ios::out | std::ios::binary) ;
output_file.sync_with_stdio(false) ;
index = 0 ;
}
inline OutoutParsing & operator << (int target) {
aux = 0 ;
n = target ;
target < 0 ? sign = -1 : sign = 1 ;
if (!n) {
nr[aux ++] = '0' ;
}
for ( ; n ; n /= 10) {
nr[aux ++] = sign * (n % 10) + '0' ;
}
if (sign == -1) {
buffer[index] = '-' ;
inc() ;
}
for ( ; aux ; inc())
buffer[index] = nr[-- aux] ;
return *this ;
}
inline OutoutParsing & operator << (const char * target) {
aux = 0 ;
while (target[aux]) {
buffer[index] = target[aux ++] ;
inc() ;
}
return *this ;
}
~OutoutParsing() {
output_file.write(buffer, index) ;
output_file.close() ;
}
private:
std::fstream output_file;
static const int SIZE = 0x200000;
int index = 0, aux, n, sign;
char buffer[SIZE], nr[24];
inline void inc() {
if (++index == SIZE) {
index = 0 ;
output_file.write(buffer, SIZE);
}
}
} ;
std::fstream in ("submultimi.in", std::ios::in) ;
OutoutParsing out ("submultimi.out") ;
int n ;
int main(int argc, const char * argv[]) {
in >> n ;
for (int i = 1 ; i < (1 << n) ; ++ i) {
for (int j = 0 ; j < n ; ++ j) {
if ((i >> j) & 1) {
out << j + 1 << " " ;
}
}
out << "\n" ;
}
}