标签:
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2020
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 68885 Accepted Submission(s):
33121
1 #include<stdio.h> 2 int main() 3 { 4 int th(int); 5 int n,i,j,b,a[100]; 6 while(scanf("%d",&n)!=EOF) 7 { 8 if(n==0) 9 break; 10 for(i=0;i<n;i++) 11 scanf("%d",&a[i]); 12 for(i=0;i<n;i++) 13 for(j=i;j<n;j++) 14 if(th(a[i])<th(a[j])) 15 { 16 b=a[i]; 17 a[i]=a[j]; 18 a[j]=b; 19 } 20 for(i=0;i<n-1;i++) 21 printf("%d ",a[i]); 22 printf("%d\n",a[i]); 23 } 24 return 0; 25 } 26 27 int th(int a) 28 { 29 if(a>=0) 30 return a; 31 else return -a; 32 }
标签:
原文地址:http://www.cnblogs.com/ruo786828164/p/5971298.html