c++wa了
查看原帖
c++wa了
356003
Moeebius楼主2021/5/18 20:43

只过了样例……

#include <bits/stdc++.h>
using namespace std;
int a[101];
int main(){
    int n,r;
    cin>>n;
    for(int i=0; i<n; i++) scanf("%d",&a[i]);
    sort(a,a+n);
    r=n;
    for(int i=0; i<n; i++){
        int x=i+1;
        while(a[x]==a[i]){
            a[x]=0;
            r--;
            x++;
        }
    }
    cout<<r<<endl;
    for(int i=0; i<n; i++){
        if(a[i]!=0) cout<<a[i]<<' ';
    }
    return 0;
}
2021/5/18 20:43
加载中...