#include
int main(void){
int n,a[10],i,j,t,index;
printf("Input n: ");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for (i=0;i<n;i++){
index=i;
for(j=1;j<n;j++){
if (a[j]<a[index])
index=j;
a[index]=t;
a[index]=a[i];
a[i]=t;}}
printf("After:");
for (i=0;i<n;i++)
printf("%d",&a[i]);
return 0 ;}
代碼應該為以下
#include
int main(void)
{
int n,a[10],i,j,t,index;
printf("Input n: ");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for (i=0;i<n;i++)
{
index=i;
for(j=1;j<n;j++){
if (a[j]<a[index])
{
index=j;
a[index]=t;
a[index]=a[i];
a[i]=t;
}
}
}
printf("After:");
for (i=0;i<n;i++)
printf("%d",&a[i]);
return 0 ;
}