讨论 / 求解答,编译器能通过,为什么评测提示超时
jazryn 2018-01-10 00:58:08
点我顶贴 收藏 删除
#include<stdio.h>

int main()

{

while(1)

{

int a;

void shuzu(int);

scanf("%d",&a);

shuzu(a);

}

return 0;

}

void shuzu(int a)

{

int b[a];

int t,jiaohuan,c;

t = 0;

while(t<a)

{

scanf("%d",&b[t]);

t = t+1;

}

t = 0;

while(t < a) //先排序

{

c = t;

while (c < a)

{

if(b[t] > b[c] )

{

jiaohuan = b[c];

b[c] =b[t];

b[t] = jiaohuan;

}

c = c+1;

}

t = t+1;

}

t = 0;

c = a;

while(t < a) //确定数字个数

{

if(t > 0 && (b[t] == b[t -1]))

c = c - 1;

t=t+1;

}

printf("%d\n",c);

t = 0;

while(t < a) //输出数字

{

if((t > 0 && b[t] != b[t -1] )|| t == 0)

printf("%d ",b[t]);

t=t+1;

}

printf("\n");

}

#1 zxcmiao@2018-01-21 20:58:49
回复 删除
是否编译正确与是否TLE有关系么?
查看更多回复
提交回复