Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 128186 Accepted Submission(s): 47663
1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int a[101]; 5 int main() 6 { 7 int n; 8 while(scanf("%d",&n)!=EOF&&n) 9 { 10 int min = 0x3f3f3f; 11 int index = -1; 12 memset(a,0,sizeof(a)/sizeof(int)); 13 for(int i = 0;i < n;++i) 14 { 15 scanf("%d",&a[i]); 16 if(min > a[i]) 17 { 18 min = a[i]; 19 index = i; 20 } 21 } 22 int t = a[0]; 23 a[0] = a[index]; 24 a[index] = t; 25 /* 26 a[0] = a[0] ^ a[index]; 27 a[index] = a[0] ^ a[index]; 28 a[0] = a[0] ^ a[index]; 29 */ 30 for(int i = 0;i < n;++i) 31 { 32 if(i==n-1) 33 { 34 printf("%d\n",a[i]); 35 break; 36 } 37 printf("%d ",a[i]); 38 } 39 } 40 return 0; 41 }
原文:https://www.cnblogs.com/knmxx/p/9374647.html