C++蒟蒻求助!!
查看原帖
C++蒟蒻求助!!
798860
tysgk楼主2022/10/8 18:29

可以正常输出排序和去重

但是数字个数统计不对啊!!!

求求各位大佬给孩子看看,呜呜呜~~~

#include<bits/stdc++.h>
using namespace std;
int main()
{
int  N,t;
cin>>N;
t=N;
int a[N];
for(int i=0;i<N;i++)
{
	cin>>a[i];
	for(int k=0;k<i;k++)
	{
	if(k==i) continue;
	if(a[i]==a[k])
	{
		a[i]=0;
		t--;
	}
	}
	}
	sort(a,a+N);
	cout<<t<<endl;
	for(int l=0;l<N;l++)
	{
	if(a[l]!=0)
	{
	cout<<a[l]<<" ";
	}
	}
	return 0;
}
2022/10/8 18:29
加载中...