Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

#include<iostream>

#include<string.h>
using namespace std;
int n,x[100];
char voc[]={"aeiou"},v[100];
void citire()
{
for(int i=1;i<=n;i++)
cin>>v[i];
}

void afisare(int k)
{
int i;
for(i=1;i<=k;i++)
cout<<v[x[i]];
cout<<endl;

}
int cont(int k)
{
int i;
for(i=1;i<k;i++)
{if(v[x[i]]==v[x[k]])
return 0;
if(strchr(voc,v[x[k]]) && strchr(voc,v[x[k-1]]))
return 0;
if(!strchr(voc,v[x[k]])&&!strchr(voc,v[x[k-1]]))
return 0;
}
return 1;
}
void bkt(int k)
{
k=1;
x[k]=0;
while(k>0)
{
while(x[k]<n)
{
x[k]++;
if(cont(k))
{
if(k==n)
afisare(k);
else
{
k++;
x[k]=0;
}
}
}
k--;
}
}

int main()
{ cout<<"Nr de caractere:";
cin>>n;
cout<<"Caractere:"<<endl;
citire();
cout<<"Combinari:"<<endl;
bkt(n);
return 0;
}

You might also like