Sinh hoanvi

#include <iostream> using namespace std; int n, kq[11], dd[10], sum = 0; void xuat() { for (int j=1; j<=n; j++) cout<< kq[j]<<" "; cout << endl; } void Hv(int i) { if (i>n) xuat(); for (int j=1; j<=n; j++) if (dd[j]==0) { dd[j]=1; kq[i]=j; Hv(i+1); dd[j]=0; } } int main() { cin >> n; for (int i=1; i<=10; i++) dd[i]=0; Hv(1); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.