Permutari - Backtracking Recursiv

  • Uploaded by: AlexNeo Alex
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Permutari - Backtracking Recursiv as PDF for free.

More details

  • Words: 50
  • Pages: 1
#include using namespace std; int st[20],n; void tipar(){ for(int i=1;i<=n;i++) cout<<st[i]<<' '; cout<<endl; } int valid(int k){ for(int i=1;i<=k-1;i++) if (st[i]==st[k]) return 0; return 1; } void back(int k){ for(int i=1;i<=n;i++){ st[k]=i; if (valid(k)) if(k==n) tipar(); else back(k+1); } } int main(){ cout<<"n = "; cin>>n; back(1); return 0; }

Related Documents

Backtracking
November 2019 16
Backtracking
April 2020 14
Backtracking
May 2020 13

More Documents from ""

Plans.pdf
November 2019 75
Tapas.docx
April 2020 45
Actividadnro01.xlsx
April 2020 59
Plans.pdf
November 2019 84