数据的交换输出
#include<stdio.h> void swap(int &x,int &y) { int temp; temp=x; x=y; y=temp; } int main( ) { int N,A[10000],i,j,min; while(scanf("%d",&N),N) { for(i=0;i<N;i++) scanf("%d",&A[i]); min=A[0]; j=0; for(i=1;i<N;i++) if(A[i]<min) { min=A[i]; j=i; } swap(A[0],A[j]); for(i=0;i<N;i++) printf(i?" %d":"%d",A[i]); puts(""); } return 0; }
posted on 2011-04-28 16:06 more think, more gains 阅读(160) 评论(0) 编辑 收藏 举报