Pagini recente » Cod sursa (job #59934) | Cod sursa (job #1448154) | Cod sursa (job #107747) | Cod sursa (job #2027407) | Cod sursa (job #2446609)
#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 = 1; i<poz; i++)
if(v[i] >= val)
return false;
return true;
}
void Back(int cnt, int x){
if(x-1 == cnt){
for(int i = 1; i<x; i++)
out << v[i] <<' ';
out <<'\n';
}
for(int i = 1; i<=N; i++){
if(verif(x, i) == true){
if(x == 0)
v[++x] = i;
else
v[x] = i;
Back(cnt, ++x);
--x;
}
}
}
int main(){
in >> N;
for(int i = 1; i<=N; i++)
Back(i, 0);
}