C语言1.用选择法对10个整数排序。10个整数用scanf函数输入。

Posted heyuchang666

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C语言1.用选择法对10个整数排序。10个整数用scanf函数输入。相关的知识,希望对你有一定的参考价值。

(1)用选择法对10个整数排序。10个整数用scanf函数输入。

#include<stdio.h>
void main()

int i,j,min,temp,a[11];
printf("enter data;\\n");
for(i=1;i<=10;i++)
printf("a[%d]=",i);
scanf("%d",&a[i]);

printf("\\n");
printf("The original numbers:\\n");
for(i=1;i<=10;i++)
printf("%5d",a[i]);
printf("\\n");
for(i=1;i<=9;i++)
min=i;
for(j=i+1;j<=10;j++)
if(a[min]>a[j])min=j;
temp=a[i];
a[i]=a[min];
a[min]=temp;

printf("\\nThe sored numbers;\\n");
for(i=1;i<=10;i++)
printf("%5d",a[i]);
printf("\\n");


以上是关于C语言1.用选择法对10个整数排序。10个整数用scanf函数输入。的主要内容,如果未能解决你的问题,请参考以下文章