冒泡排序
#include <stdio.h>
int main()
{
int s[10]={12,65,32,69,5,8,21,36,4,15};
int i=0,j=0,c=0,b=0;
int len=sizeof(s)/sizeof(int);
for(i=0;i<len;i++)
{
printf("%d ",s[i]);
}
printf("\n");
for(j=0;j<len-1;j++)
{
c=0;
for(i=0;i<len-1-j;i++)
{
if(s[i]>s[i+1])
{
b=s[i];
s[i]=s[i+1];
s[i+1]=b;
c=1;
}
}
if(c==0){
break;
}
}
for(i=0;i<len;i++)
{
printf("%d ",s[i]);
}
printf("\n");
return 0;
}
标签:10,12,15,int,冒泡排序,sizeof
From: https://www.cnblogs.com/yesiming/p/17432778.html