POJ 2388 排序
来源:互联网 发布:林心如律师发声明知乎 编辑:程序博客网 时间:2024/05/29 03:25
//无聊玩玩vector"一等公民"#include<iostream>#include<vector>#include <algorithm>using namespace std;int main(){ int i, N; cin >> N; vector<int>arr(N); for (i = 0; i < N; i++) cin >> arr[i]; sort(arr.begin(), arr.end()); cout << arr[N / 2] << endl; return 0;}
开始RE的代码:
#include <iostream>#include <algorithm>using namespace std;int a[1005];int main(){ int N; cin>>N; for(int i=0;i<N;i++) { cin>>a[i]; } sort(a,a+N); cout<<a[((1+N)/2)-1]<<endl; return 0;}改了一下就过了
#include <iostream>#include <algorithm>using namespace std;int a[10005];int main(){ int N; cin>>N; for(int i=0;i<N;i++) { cin>>a[i]; } sort(a,a+N); int ans=(1+N)/2-1; cout<<a[ans]<<endl; return 0;}
0 0
- POJ 2388(快速排序)
- POJ 2388(排序)
- poj 2388 堆排序
- POJ 2388 排序
- POJ 2388快速排序
- 堆排序练习:POJ 2388
- POJ 2388 排序水题
- poj 2388(超水) 排序
- POJ 2388 (堆排序求中位数)
- 直接插入排序练习:POJ 2388
- poj[2487]排序题
- POJ-1002(字符串+排序)
- 拓扑排序,poj 1094
- 拓扑排序,poj 1094
- POJ 1094 拓扑排序
- poj-1094拓扑排序
- poj 1094 拓扑排序
- POJ 2299 归并排序
- LeanCloud Demos分类汇总
- ob缓冲实例
- 如何通过JQ,Ajax来实现返回到上一个页面并进行刷新
- ListView 优化总结
- Android 事件分发机制(最新源码6.0分析)--ViewGrop
- POJ 2388 排序
- 动画加载ListView
- css选择器与jquery选择器
- 良好的代码规范 -- 缩进
- strutus2中获得jsp页面的元素值
- UVA - 712 S-Tree
- 欢迎使用CSDN-markdown编辑器
- ROS by Example 第2卷 -- 概括
- UVA - 327 Evaluating Simple C Expressions