1481谁考了第k名
#include#include using namespace std; typedef struct stu { int id; float score; }stu; stu p[100]; bool cmp1(stu a,stu b) { return a.score>b.score; } int main() { int n,k,i; cin>>n>>k; for(i=1;i<=n;i++) cin>>p[i].id>>p[i].score; sort(p+1,p+1+n,cmp1); i=k; cout<
1482奇数单增序列
#include#include using namespace std; int main() { int n,i,j=1; int a[505],b[505]; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n;i++) { if(a[i]%2==1) b[j++]=a[i]; } sort(b+1,b+1+j-1); for(i=1;i 1483成绩排序
#include#include using namespace std; typedef struct stu { char name[25]; int score; }stu; stu p[20]; bool cmp(stu a,stu b) { if(a.score==b.score) return a.name[0] b.score; } int main() { int n,i; cin>>n; for(i=1;i<=n;i++) cin>>p[i].name>>p[i].score; sort(p+1,p+1+n,cmp); for(i=1;i<=n;i++) cout<
554老和尚的导员
#include#include #include using namespace std; typedef struct stu { int id; int a; int b; int c; int d; int score; }stu; stu p[105]; bool cmp(stu x,stu y) { if(x.score!=y.score) return x.score>y.score; else if(x.a!=y.a) return x.a>y.a; else if(x.b!=y.b) return x.b>y.b; else if(x.c!=y.c) return x.c>y.c; else return x.d>y.d; } int main() { int n,i; while(scanf("%d",&n)!=EOF) {for(i=1;i<=n;i++) { cin>>p[i].a>>p[i].b>>p[i].c>>p[i].d; p[i].id=i; p[i].score=p[i].a+p[i].b+p[i].c+p[i].d; } sort(p+1,p+1+n,cmp); for(i=1;i<=n;i++) cout<
556健忘的老和尚
#include#include #include using namespace std; typedef struct stu { char name[105]; int score; }stu; stu p[105]; bool cmp(stu x,stu y) { return x.score >p[i].name>>p[i].score; } sort(p+1,p+1+n,cmp); for(i=n-m+1;i<=n;i++) cout<
873戏说三国
#include#include #include using namespace std; typedef struct stu { char name[25]; double score,a,b,c; }stu; stu p[100000]; bool cmp(stu x,stu y) { if(x.score!=y.score)return x.score>y.score; else if(x.a!=y.a)return x.a>y.a; else if(x.b!=y.b)return x.b>y.b; else return x.c>y.c; } int main() { int n,t,i,j; float an,bn,cn; while(scanf("%d",&t)!=EOF) { for(j=0;j >p[i].name>>p[i].a>>p[i].b>>p[i].c; p[i].score=p[i].a*an+p[i].b*bn+p[i].c*cn; } sort(p+1,p+1+n,cmp); printf("Case #%d:n",j+1); for(i=1;i<=n;i++) printf("%s %.4f %.4f %.4f %.4fn",p[i].name,p[i].score,p[i].a*an,p[i].b*bn,p[i].c*cn); } } return 0; } 874相约摩洛哥
#include#include #include using namespace std; typedef struct stu { char name[15]; int a,b,c,A,B,C; int ts; int time; }stu; stu p[100000]; bool cmp(stu x,stu y) { if(x.ts!=y.ts)return x.ts>y.ts; else return x.time >p[i].name>>p[i].a>>p[i].b>>p[i].c; for(i=1;i<=n;i++) cin>>p[i].A>>p[i].B>>p[i].C; for(i=1;i<=n;i++) { p[i].ts=0; if(p[i].a!=-1)p[i].ts++; if(p[i].b!=-1)p[i].ts++; if(p[i].c!=-1)p[i].ts++; } for(i=1;i<=n;i++) { p[i].time=0; if(p[i].a!=-1)p[i].time=p[i].time+p[i].a+(p[i].A-1)*20; if(p[i].b!=-1)p[i].time=p[i].time+p[i].b+(p[i].B-1)*20; if(p[i].c!=-1)p[i].time=p[i].time+p[i].c+(p[i].C-1)*20; } sort(p+1,p+1+n,cmp); for(i=1;i<=n;i++) cout<
1297结构体排序题一
#include#include #include using namespace std; typedef struct stu { int m,n; }stu; stu p[100000]; bool cmp1(stu x,stu y) { if(x.m!=y.m)return x.m>y.m; else return x.n>y.n; } bool cmp2(stu x,stu y) { if(x.m!=y.m)return x.m y.n; } bool cmp3(stu x,stu y) { if(x.m!=y.m)return x.m>y.m; else return x.n >p[i].m>>p[i].n; if(a==0&&b==0)sort(p+1,p+1+n,cmp1); else if(a==1&&b==0)sort(p+1,p+1+n,cmp2); else if(a==0&&b==1)sort(p+1,p+1+n,cmp3); else if(a==1&&b==1)sort(p+1,p+1+n,cmp4); for(i=1;i<=n;i++) cout<<"("<
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)