标签:结构体排序 结构 span pac hdu bool names == nbsp
hdu2019:
#include<bits/stdc++.h> using namespace std; const int maxn=110; int a[maxn]; int main() { int N,x; while(~scanf("%d%d",&N,&x)){ if(N==0&&x==0) break; N++; a[N]=x; for(int i=1;i<N;i++) scanf("%d",&a[i]); sort(a+1,a+N+1); for(int i=1;i<N;i++) printf("%d ",a[i]); printf("%d\n",a[N]); } return 0; }
hdu2020:
#include<bits/stdc++.h> using namespace std; const int maxn=110; int a[maxn]; bool cmp(int w,int v){ return abs(w)>abs(v); } int main() { int N; while(~scanf("%d",&N)){ if(N==0) break; for(int i=1;i<=N;i++) scanf("%d",&a[i]); sort(a+1,a+N+1,cmp); for(int i=1;i<N;i++) printf("%d ",a[i]); printf("%d\n",a[N]); } return 0; }
标签:结构体排序 结构 span pac hdu bool names == nbsp
原文地址:https://www.cnblogs.com/hua-dong/p/9915797.html