標(biāo)題:
選擇排序
[打印本頁]
作者:
51hei單片
時(shí)間:
2016-3-13 17:00
標(biāo)題:
選擇排序
void main()
{
int i,j,min,temp;
int a[10];
printf("請輸入十個(gè)整數(shù):");
for(i=0;i<=9;i++)
scanf("%d",&a[i]);
for(i=0;i<9;i++)
{
min=i;
for(j=i+1;j<=9;j++)
{
if(a[min]>a[j])
{
min=j;
}
temp=a[j];
a[j]=a[min];
a[min]=temp;
}
}
for(i=0;i<=9;i++)
printf("%4d",a[i]);
}
復(fù)制代碼
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1