Pagini recente » Cod sursa (job #3197016) | Cod sursa (job #966001) | Cod sursa (job #1766459) | Cod sursa (job #2678925) | Cod sursa (job #2446612)
#include <fstream>
using namespace std;
ifstream in("submultimi.in");
ofstream out("submultimi.out");
int N, v[17];
bool verif(int poz, int val){
for(int i = 0; i<poz; i++)
if(v[i] >= val)
return false;
return true;
}
void Back(int cnt, int x){
if(x == cnt){
for(int i = 0; i<x; i++)
out << v[i] <<' ';
out <<'\n';
}
for(int i = 1; i<=N; i++){
if(verif(x, i) == true){
v[x] = i;
Back(cnt, ++x);
--x;
}
}
}
int main(){
in >> N;
for(int i = 1; i<=N; i++)
Back(i, 0);
}