Hdoj 2673 shǎ崽 OrOrOrOrz
来源:互联网 发布:怎么加入淘宝类目群 编辑:程序博客网 时间:2024/05/01 23:43
Problem Description Acmer in HDU-ACM team are ambitious, especiallyshǎ崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz him. But Orz him is not that easy.You must solve this problem first. The problem is : Give you a sequence of distinct integers, choose numbers as following : first choose th biggest, then smallest, then second biggest, second smallest etc. Until all the numbers was chosen . For example, give you 1 2 3 4 5, you should output 5 1 4 2 3
Input There are multiple test cases, each case begins with one integer
N(1 <= N <= 10000), following N distinct integers.Output Output a sequence of distinct integers described above.
Sample Input
5 1 2 3 4 5
题目分析:
输入数据后排序一次再设置2个指针和一个flag即可交替输出
Code
#include<iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<cctype>#include<cstring>#include<cstdlib>using namespace std;const int maxn=10001;int a[maxn];int main() { int n; while(cin>>n) { for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+n+1); bool flag=true; int p1=0;int p2=n+1; while(n--) { if(!flag) { p1++; cout<<a[p1]; if(n) cout<<" "; flag= true; }else { p2--; cout<<a[p2]; if(n) cout<<" "; flag= false; } } cout<<endl; } return 0;}
- hdoj-2673-shǎ崽 OrOrOrOrz
- Hdoj 2673 shǎ崽 OrOrOrOrz
- hdoj 1.3.3(shǎ崽 OrOrOrOrz)
- 2673 shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- HDOJ 2673 shǎ崽 OrOrOrOrz
- HDU 2673 shǎ崽 OrOrOrOrz
- hdu 2673 shǎ崽 OrOrOrOrz
- hdu 2673 shǎ崽 OrOrOrOrz
- HDU 2673:shǎ崽 OrOrOrOrz
- HDU 2673 shǎ崽 OrOrOrOrz (排序)
- 杭电2673 shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz hdu2673
- HDU2673:shǎ崽 OrOrOrOrz
- HDU shǎ崽 OrOrOrOrz
- HDU2673----shǎ崽 OrOrOrOrz
- python文件定位读取
- 谈谈8年C++面向对象设计的经验体会
- caffe 在 windows 下的配置(scripts\build_win.cmd)
- SSL P2324 细胞问题 题目
- Automatic fall detection of human in video using combination of features译文
- Hdoj 2673 shǎ崽 OrOrOrOrz
- Gym
- ViewPager与Recycleview控件
- AssetBundle自动打包工具
- 方差,均方差,标准差,协方差
- shell脚本(二)练习题目
- C/C++相关知识点随记(持续更新)
- 基础练习 十六进制转八进制
- leetcode 520. Detect Capital 检查大小写