灵异事件
查看原帖
灵异事件
530048
24kcsplus楼主2021/9/11 23:05

明明跟题解的输出一样,样例输出也正常,但不知为啥全是WA,求大佬解答 附上本蒟蒻写的代码:

#include <bits/stdc++.h>
using namespace std;

int main(){
	int a[1005],b,i,n,g;
	bool pd[1005];
	cin >> n;
	b=n;
	for (i=0;i<n;i++){
		cin >> a[i];
		if (pd[a[i]]==true) {
			b--;
			for(g=i;g<n;g++) {
				a[i]=a[i+1];
				}
			continue;
			}
		pd[a[i]]=true;
	}
	sort(a,a+n);
	cout<<b<<endl;
	for (i=0;i<n;i++) if(a[i]) cout<<a[i]<<" ";
}

渣作,勿喷

2021/9/11 23:05
加载中...