AC

root  •  2年前


include

int shu[1000]; int s[1000]; using namespace std; int main() {

int a,b,num=0,temp=0,m=0,k=0;
scanf("%d",&a);
for(int i=1;i<=a;i++)
{
scanf("%d",&shu[i]);
b=shu[i];
s[b]=s[b]+1;
 if (s[b] == 1)
        num++;
    if (s[b] > 1)
        shu[i] = 0;

} printf("%d\n",num); for (int i = 1; i <= a; i++) {

    if (shu[i] != 0) {
        k++;
        shu[k] = shu[i];
    }
}

for (int j = 1; j <= num; j++) {

    m = j;
    for (int i = j + 1; i <= num; i++)
        if (shu[i] < shu[m] && shu[i] != 0)
            m = i;
    temp = shu[j];
    shu[j] = shu[m];
    shu[m] = temp;
}

for(int i=1;i<=num;i++) printf("%d ",shu[i]); return 0; }


评论:

请先登录,才能进行评论