#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
int a[10],b[10];
int i,j,count=0;
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
for(j=0;j<i;j++)
{
if(a[i]==a[j])
{
break;
}
}
if(j==i)
{
b[count]=a[i];
count++;
}
}
int t;
for(i=0;i<count-1;i++)
{
for(j=0;j<count-1-i;j++)
{
if(b[j]>b[j+1])
{
t=b[j];
b[j]=b[j+1];
b[j+1]=t;
}
}
}
for(i=0;i<count;i++)
{
printf("%d\n",b[i]);
}
}
总是提交不成功,但我试的又是对的,
我的思路是先找出不同的数,在冒泡排序