2024-09-22 06:34:41
2024-09-22 00:31:53
#include<stdio.h>
#define N 10
void main() { int i,j,k,a[N];
for ( i=0;i<N;i++ ) scanf("%d",&a[i]);
for ( i=0;i<N-1;i++ )
for ( j=i+1;j<N;j++ )
if ( a[i]>a[j] ) { k=a[i]; a[i]=a[j]; a[j]=k; }
for ( i=0;i<N;i++ ) printf("%d ",a[i]); printf("\n");
}
2024-09-22 06:39:22
#include "stdio.h"
#define N 10
int main(int argc,char *argv[]){
int a[N],i,j,k;
printf("Please enter %d integer(s)...\n",N);
for(i=0;i<N;scanf("%d",a+i++));//输入
printf("\nAfter ascending sort of output:\n");
for(i=0;i<N;i++){
for(k=i,j=k+1;j<N;j++)
if(a[k]>a[j])
k=j;
if(k!=i)
j=a[k],a[k]=a[i],a[i]=j;
printf("%d ",a[i]);
}
printf("\n");
return 0;
}
代码和运行样例图片:
2024-09-22 02:50:34
2024-09-22 06:18:47