[C] 纯文本查看 复制代码
#include
#define N 11
int main(void)
{
int a[N] = {70,30,40,10,80,20,90,100,78,60,45} ;
int i, j , temp;
printf("原序列为:") ;
for(i=0 ;i<n ;++i)
printf("%d ",a[i]) ;
/*选择排序*/
for(i=0; i<n-1; ++i)
{
for(j=i+1; j<n; ++j)
{
if(a[i]>a[j])
{
temp = a[i] ;
a[i] = a[j] ;
a[j] = temp ;
}
}
}
printf("排后序列:") ;
for(i=0; i<n; ++i)
printf("%d ",a[i]) ;
printf("") ;
return 0 ;
}