#include
#define N 10
void main( )
{
int a[N]= {6,5,8,1,0,4,7,3,2,9} //掉了分号
int i,j,t;
printf(“The array before sorted:”);
for(i=0;i
for(i=N;i>0;i--)
{
for(j=0;j
for (i=0;i
}
int []score={6,5,8,1,0,4,7,3,2,9};
for(int i=0;i
for(int j=1;j
a=j;
}
}
int tmp=score[score.length-1-i];
score[score.length-1-i]=score[a];
score[a]=tmp;
}
for (int k=0;k
}
可以用冒泡排序法实现数组的升序排列。
for(i=0;i
for(j=0;j
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
#include
#define N 10
int main( )
{
int a[N]= {6,5,8,1,0,4,7,3,2,9};
int i,j,t,key,tmp;
printf("The array before sorted:");
for(i=0; i
for(i=0; i
key=a[i];
for(j=i+1; j
{
tmp=key;
key=a[j];
a[j]=tmp;
}
a[i]=key;
}
printf("The array after sorted:");
for (i=0; i
return 1;
}
#include
#define N 10
void main( )
{
int a[N]= {6,5,8,1,0,4,7,3,2,9}
int i,j,t;
printf(“The array before sorted:”);
for(i=0;i
for(i=0;i<9;i++)
{
for(j=i+1;j<10;j++)
{ if(a[i]>a[j])
{ t=a[i];a[i]=a[j];a[j]=t;
}}}
printf(“The array after sorted:”);
for(i=0;i
}