1408191944-hd-shǎ崽 OrOrOrOrz.cpp
来源:互联网 发布:女 欧 t恤 知乎 编辑:程序博客网 时间:2024/05/22 01:28
shǎ崽 OrOrOrOrz
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3853 Accepted Submission(s): 1193
Problem Description
Acmer in HDU-ACM team are ambitious, especially shǎ崽, 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 the 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
51 2 3 4 5
Sample Output
5 1 4 2 3
题目大意
给你一个不同的整数序列,依次输出号码如下:首先选择最大的,然后第二的最小,最大,最小二等选择所有的号码。
注意事项
要注意给出的长度是奇数还是偶数,分别考虑。
代码
#include<stdio.h>#include<algorithm>using namespace std;int s[11000];int main(){int n;int i,j,k;while(scanf("%d",&n)!=EOF){for(i=0;i<n;i++) scanf("%d",&s[i]);sort(s,s+n);k=n/2;for(i=0,j=n-1;i<k;i++,j--){printf("%d %d",s[j],s[i]);if(i!=k-1)printf(" ");}if(n%2==1)//长度是奇数的时候要另外考虑 printf(" %d",s[k]);printf("\n");}return 0;}
- 1408191944-hd-shǎ崽 OrOrOrOrz.cpp
- shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz hdu2673
- HDU2673:shǎ崽 OrOrOrOrz
- HDU shǎ崽 OrOrOrOrz
- HDU2673----shǎ崽 OrOrOrOrz
- HDU2673:shǎ崽 OrOrOrOrz
- 2673 shǎ崽 OrOrOrOrz
- HDU shǎ崽 OrOrOrOrz
- HDU shǎ崽 OrOrOrOrz
- F - shǎ崽 OrOrOrOrz
- HDU 2673 shǎ崽 OrOrOrOrz
- hdu 2673 shǎ崽 OrOrOrOrz
- hdu 2673 shǎ崽 OrOrOrOrz
- HDU 2673:shǎ崽 OrOrOrOrz
- hdoj 1.3.3(shǎ崽 OrOrOrOrz)
- 搜索引擎优化SEO 十大高级搜索指令
- UIWindow简单介绍
- 吴军:百分之百好的事不能做
- 分享下速卖通api的java的入门代码
- java编写投票功能需求分析
- 1408191944-hd-shǎ崽 OrOrOrOrz.cpp
- Windows中VirtualBox虚拟机实现桥接方式(Bridged Adapter)
- 团队管理
- Eclipse统计代码行数
- Linux 添加用户 ,帐号管理 ,群组管理 详解
- zoj 1010
- Java基础<异常机制>总结(异常体系、Exception特点、异常处理方式)
- ANTLR4权威指南 - 第5章 设计语法
- 淘宝数据库OceanBase SQL编译器部分 源码阅读--解析SQL语法树