The 6th Zhejiang Provincial Collegiate Programming Contest->ProblemA:Second-price Auction
2016-02-25 21:59
405 查看
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3202
题意:拍卖东西,以第二高价的价格卖给出第一高价的人。输出最后获得东西的人的序号和要出的价钱。
思路:(最笨的方法)用结构体来排序。
题意:拍卖东西,以第二高价的价格卖给出第一高价的人。输出最后获得东西的人的序号和要出的价钱。
思路:(最笨的方法)用结构体来排序。
#include<bits/stdc++.h> using namespace std; struct hzx { int id; int a; }; int comp1(const void *p,const void *q) { return ((struct hzx *)p)->a-((struct hzx *)q)->a; } int main() { int t,n; struct hzx aa[101]; cin>>t; while(t--) { cin>>n; for(int i=0; i<n; i++) { cin>>aa[i].a; aa[i].id=i; } qsort(aa,n,sizeof(struct hzx),comp1); printf("%d %d\n",aa[n-1].id+1,aa[n-2].a); } return 0; }
相关文章推荐
- 练习题
- BZOJ1196 [HNOI2006] 公路修建问题
- 供应链电子商务
- cobbler安装centos系统
- 深度学习的浅实践:开源软件/数据库实现表情识别(2)
- Android画图最基本的三个对象(Color,Paint,Canvas)
- 《JAVA编程思想》日志(二)-----一切都是对象
- PB调用WebService
- 指针与引用的区别
- 2016十家公司前端面试小记
- poj 1604
- C#开发:openfiledialog的使用
- BZOJ-4010 菜肴制作 贪心+堆+(拓扑图拓扑序)
- Remove Duplicates from Sorted Array II
- 代理block(一)
- iOS 3D Touch使用<一、 Home Screen Quick Actions使用>
- 广播、多播和IGMP的一点记录
- BZOJ-4010 菜肴制作 贪心+堆+(拓扑图拓扑序)
- Android 初探OpenGL ES
- 乱弹地信产业园