/*
第二題:去除重複字符並排序
運行時間限制:無限制
內容限制: 無限制
輸入: 字符串
輸出: 去除重複字符並排序的字符串
樣例輸入: aabcdefff
樣例輸出: abcdef
[cpp] view plaincopy */
#include"stdio.h"
#include"string.h"
char s[100];
char b[100];
int main()
{
int n;
gets(s);
n=strlen(s);
int i,j,count=0;
for (i=0;i<n;i++)
{ j=0;
while(s[i]!=b[j]&&j<count)//對b進行搜索
{
j++;
}
if(j==count)
{
b[count]=s[i];
count++;
}
}
n=strlen(b);
for(i=0;i<n;i++)//冒泡排序
{
for(j=i;j<n;j++)
{
if(b[i]>b[j])
{ char t;
t=b[i];
b[i]=b[j];
b[j]=t;
}
}
}
for(i=0;i<n;i++)
{printf("%c",b[i]);
}
}