Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //aranjamente
- #include<iostream>
- #include <string.h>
- using namespace std;
- int st[20],n,k;
- char nume[5][20];
- char nume2[1][20];
- void init()
- {
- int i;
- cout<<"n=";cin>>n;
- cout<<"k=";cin>>k;
- for(i=1;i<=n;i++)
- {
- st[i]=0;
- cin>>nume[i];
- }
- }
- void tipar(int p)
- {
- int j;
- for(j=1;j<=p;j++)
- cout<<nume[j]<<" ";
- cout<<endl;
- }
- int valid(int p)
- {
- int i,ok;
- ok=1;
- for(i=1;i<p;i++)
- if(strcmp(nume[p],nume[i]) == 0)
- ok=0;
- return ok;
- }
- int solutie(int p)
- {
- return (p==k);
- }
- void bkt(int p)
- {
- int val;
- for (val=1;val<=n;val++)
- {
- st[p]=val;
- if (valid(p))
- if(solutie(p))
- tipar(p);
- else
- bkt(p+1);
- }
- }
- int main()
- {
- init();
- bkt(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement