# 取子串,要求子串不重复。

``abcd``

``````abc
abd
acd
bcd``````

``````#include<stdio.h>
#include<string.h>
int l;
void dfss(char str[],char ch[],int x,int k)
{
int i,j;
if (k==2) {
for (i=0;i<=2;i++)
printf("%c",ch[i]);
printf("\n");
return ;
}

for (i=x+1;i<=l;i++)
if (ch[k]<str[i])
{
ch[k+1]=str[i];

dfss(str,ch,i,k+1);
}
return ;

}
int main ()
{
int x,y,i,j;
char str[1000],ch[3];
gets(str);
l=strlen(str);
for (i=0;i<=l-3;i++)
{
ch[0]=str[i];
dfss(str,ch,i,0);

}
return 0;

}``````

``````#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

void getdf(char arr1[],char arr2[])
{
int len1=strlen(arr1),len2=0;
for(int i=0;i<len1;i++)
{
int flag=0;
if(len2==0)
{
arr2[0]=arr1[0];
len2++;
continue;
}
else
{
for(int j=0;j<len2;j++)
{

if(arr1[i]!=arr2[j])
{
flag=0;
continue;
}
else
{
flag=1;
break;
}
}
}
if(flag==0)
{
arr2[len2++]=arr1[i];
}
}
arr2[len2]='\0';
}

bool cmp(char a,char b)
{
return a<b;
}

int main()
{
char arr1[30],arr2[30];
cin>>arr1;
getdf(arr1,arr2);
int leng=strlen(arr2);
sort(arr2,arr2+leng,cmp);

for(int i=0;i<leng-2;i++)
for(int j=i+1;j<leng-1;j++)
for(int k=j+1;k<leng;k++)
{
cout<<arr2[i]<<arr2[j]<<arr2[k]<<endl;
}
return 0;
}

``````