Pagini recente » Cod sursa (job #484305) | Cod sursa (job #2510760) | Cod sursa (job #909721) | Cod sursa (job #1772819) | Cod sursa (job #1990059)
#include <iostream>
#include <fstream>
#include <vector>
void subs(std::ostream &out, std::vector<int> &myV, int nV) {
int start = 1;
if (!myV.empty()) {
for (int v : myV) {
out << v << ' ';
}
out << '\n';
start = myV.back() + 1;
}
for (; start <= nV; start++) {
myV.push_back(start);
subs(out, myV, nV);
myV.pop_back();
}
}
int main() {
std::ifstream fileIn("submultimi.in");
std::ofstream fileOut("submultimi.out");
int nV;
fileIn >> nV;
std::vector<int> myV;
subs(fileOut, myV, nV);
fileIn.close();
fileOut.close();
return 0;
}