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
5 1 2 3 4 5
 
Sample Output
5 1 4 2 3
 
//大水题。。但是要注意格式
 
 #include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; int main()
{
int n,i;
int data[];
while(cin>>n)
{
for(i=;i<=n;i++)
scanf("%d",&data[i]);
sort(data+,data++n);
if(n%==)//有偶数个4/2=2 4 1 3 2
{
for(i=n;i>n/+;i--)
cout<<data[i]<<" "<<data[n-i+]<<" ";
cout<<data[i]<<" "<<data[n-i+]<<endl;//否则PE
}
else//有奇数个 5/2=2 5 1 4 2 3
{
for(i=n;i>n/+;i--)
cout<<data[i]<<" "<<data[n-i+]<<" ";
cout<<data[n/+]<<endl;
} }
return ;
}

HDU2673:shǎ崽 OrOrOrOrz的更多相关文章

  1. HDU 2673 shǎ崽 OrOrOrOrz

    #include <cstdio> #include <algorithm> using namespace std; int main() { int n; while (s ...

  2. hdu 1.3.4 shǎ崽 OrOrOrOrz

    简单的排序,注意输出即可 #include <iostream> #include <algorithm> using namespace std; int main() { ...

  3. [acm]HDOJ 2673 shǎ崽 OrOrOrOrz

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2673 拍两次序,交替输出 #include<iostream> #include< ...

  4. hdu 2671 shǎ崽 OrOrOrOrz(排序)

    题意:排序后按题目要求输出 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using ...

  5. hdu-2673-shǎ崽 OrOrOrOrz(水题)

    注意输出格式 #include <iostream> #include <algorithm> using namespace std; +]; int main() { in ...

  6. HDU 2673-shǎ崽 OrOrOrOrz(C语言描述)

    问题描述 问题是: 为您提供了一系列不同的整数, 请选择 "数字" 如下: 首先选择最大的, 然后是最小的, 然后是第二个最大的, 第二个最小的. 直到所有的数字被选中.例如, 给 ...

  7. HDU1029时钟(排序)

    题意:是用两个指针的一个模拟时钟的时针和分针.两个指针形成一个角度.角度测量两个指针之间的最小角度.两只手之间的角度是大于或等于0,且小于或等于180度的度量.由于一个序列的五个不同的写入时间,格式为 ...

  8. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  9. 【转】ACM博弈知识汇总

    博弈知识汇总 转自:http://www.cnblogs.com/kuangbin/archive/2011/08/28/2156426.html 有一种很有意思的游戏,就是有物体若干堆,可以是火柴棍 ...

随机推荐

  1. sql server 2012提示评估期已过的解决办法 附序列号

    sql server 2012提示评估期已过的解决方法: 第一步:进入SQL2012配置工具中的安装中心. 第二步:再进入左侧维护选项界面,然后选择选择版本升级. 第三步:进入输入产品密钥界面,输入相 ...

  2. 二十七、oracle 例外

    一.例外分类oracle将例外分为预定义例外.非预定义例外和自定义例外三种.1).预定义例外用于处理常见的oracle错误.2).非预定义例外用于处理预定义例外不能处理的例外.3).自定义例外用于处理 ...

  3. slf4j 之logback日志之sl4j架构【二】

    一.整体介绍 介绍: The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for v ...

  4. 一些常见的CFD基本概念(飞机为例)(摘抄)

    分享一些常见的,常用的但不容易掌握的CFD基础概念. 1.理想气体:不考虑流体粘性的影响. 2.不可压缩流体/恒密度:不考虑流体密度的变化.

  5. bower工具的简单使用

    基于NodeJS的一个静态资源管理工具,由twitter公司开发维,解决大型网站中静态资源的依赖问题. 1.依赖NodeJS环境和git工具. 2.npm install -g bower安装bowe ...

  6. android app 集成 信鸽推送

    推送其实挺中意小米推送的,并经用户群占比还是比较大的,奈何拗不过php后端哥们的选型,就只好用信鸽推送了,期间接入过程中也是遇到不少问题,所以记录下来,以后如果还是用信鸽推送的话,估计看看以前的博客, ...

  7. Inverse属性和cascade属性以及集合的多对多关系

    Inverse属性 Inverse属性,是在维护关联关系的时候起作用的. 表示控制权是否转移.(在一的一方起作用) Inverse = true, 控制反转. Inverse = false  不反转 ...

  8. 【LeetCode】423. Reconstruct Original Digits from English

    Given a non-empty string containing an out-of-order English representation of digits 0-9, output the ...

  9. sql 多个字段排序,头一个字段排序完,再对第二个字段进行排序(以此类推)

    现根据num排序,num数字相同的根据时间进行排序,都是降序DESC SELECT * FROM counts ORDER BY num DESC,create_time DESC

  10. submit 防止重复提交 --禁止提交

    <form action="/apply/apply" method="POST" id="indentForm"> <p ...