Poj2388_Who's in the Middle
来源:互联网 发布:分期付款算法 编辑:程序博客网 时间:2024/04/27 17:50
这题十分水,不过顺便学了下c++里的sort排序
两个参数时,默认为升序排序sort(初始位置,结束位置后一位)
三个参数时,自定义一个方法进行降序排序 sort(初始位置,结束位置后一位,cmp) 例如
bool cmp(int a,int b)
{
if(a>=b)
return true;
else
return false;
}
#include <cstdio>#include <cstdlib>#include <iostream>#include <algorithm>#include <cstring>using namespace std;const int maxn=10010;int cow[maxn];int main(){ int cownumber; while(cin>>cownumber) { memset(cow,0,sizeof(cow)); for(int i=0;i<cownumber;i++) { scanf("%d",&cow[i]); } sort(cow,cow+cownumber); cout<<cow[cownumber/2]<<endl; } return 0;}
0 0
- Poj2388_Who's in the Middle
- PKU_ACM_2388_Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- hdu1157Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- hdu1157Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- Who's in the Middle
- 如何在你的cocos2dx中使用sqlite3
- 14.线性表之链栈的基本操作
- 在公司3个月的一些积累
- Collections集合工具类
- 可计算代数数论(2012-12-09 20:56、2013-03-23 21:39、2013-06-23 20:27、2013-06-23 20:32、2014-05-16 17:49)
- Poj2388_Who's in the Middle
- Oracle的主要进程简要
- Codeforces Round #328 (Div. 2)A. PawnChess
- Why Floating-Point Numbers May Lose Precision
- 解决cocos2dx CCArmature动画在部分型号的安卓手机上播放不正常的问题
- 关于CCArmature加载时因为plist中含有相同名称的图片导致碰撞框被冲掉的解决办法。
- ubuntu 改时区
- 黑马程序员视频加源码
- eclipse for android安装过程