Pagini recente » Cod sursa (job #1698200) | Cod sursa (job #3248844) | Cod sursa (job #1464637) | Cod sursa (job #1196205) | Cod sursa (job #3355039)
{\rtf1\ansi\ansicpg1252\cocoartf2868
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\f0\fs24 \cf0 #include <cmath>\
#include <cstdio>\
#include <vector>\
#include <iostream>\
#include <algorithm>\
using namespace std;\
\
\
int n, lun;\
vector<int> vizitat;\
vector<int> solutie;\
\
void backtracking(int k) \{\
if (k > lun) \{\
for (int i = 1; i <= lun; i++) \{\
cout<<solutie[i]<<' ';\
\}\
cout<<"\\n";\
return;\
\}\
for (int candidat = 1; candidat <= n; candidat++) \{\
\
if (k > 1 && solutie[k - 1] >= candidat) continue;\
\
solutie[k] = candidat;\
\
backtracking(k + 1);\
\
\
\}\
\}\
\
int main() \{\
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ \
cin>>n>>lun;\
vizitat.resize(n + 1, 0);\
solutie.resize(n + 1);\
backtracking(1);\
return 0;\
\}}