萌新求助!测试了几组数据没问题但是一提交全部WA。。
查看原帖
萌新求助!测试了几组数据没问题但是一提交全部WA。。
629096
NoobMaster楼主2021/11/24 22:22
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void main()
{
    int m[100]={0};
	int count,n,a,i,j,k,l;
	int count1=0;
	char ch;
	i=0;
	scanf("%d",&n);
	do
	{
	  count=0;
      scanf("%d%c",&a,&ch);
	  for(j=0;j<i;j++) if(m[j]==a) count++;//去重
	  if(count==0)
	  {
	    m[i]=a;
	    i++;
	  }
	  count1++;
	}while(count1<n);
	for(k=0,j=i/2;j!=0;j/=2)//排序
	{
		l=0;
		while(m[j+l]!=0)
		{
			if(m[k+l]>m[j+l]) {a=m[k+l],m[k+l]=m[j+l];m[j+l]=a;}
			l++;
		}
	}
	printf("%d\n",i);
	for(j=0;j<i;j++) printf("%d ",m[j]);
	printf("\n");
	system("pause");
}
2021/11/24 22:22
加载中...