hello world,熬夜小王子要猝死了,我这个又算复习一遍了

#include<stdio.h>
 int main()
 {
  int i,j;
  int a[10];
  int temp;
  int ipos;
  printf("为数组元素赋值:\n");
  for(i=0;i<10;i++)
  {
  printf("a[%d]=",i);
  scanf("%d",&a[i]);
}
for(i=0;i<9;i++)
{
temp=a[i];
ipos=i;
for(j=i+1;j<10;j++)
{
if(a[j]<temp)
{
temp=a[j];
ipos=j; 
}
}
a[ipos]=a[i];
a[i]=temp;
}
for(i=0;i<10;i++)
{
printf("%d\t",a[i]);
if(i==4)
printf("\n");
}
return 0;
 
 }

猜你喜欢

转载自www.cnblogs.com/redxi/p/10859944.html