【转】http://blog.csdn.net/zxy_snow/article/details/6152043
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n,x,a[101],count,i,k,flag;
while( scanf("%d",&n) != EOF && n )
{
count = 0;
for(i=0; i<n; i++)
{
flag = 0;
scanf("%d",&x);
for(k=0; k<count; k++)
if( a[k] == x )
{
flag = 1;
break;
}
if( !flag ) a[count++] = x;
}
sort( a, a+count );
printf("%d",a[0]);
for(i=1; i<count; i++)
printf(" %d",a[i]);
printf("/n");
}
return 0;
}