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. HeartBeat源码安装

    只是写了安装流程,具体信息查看互联网; 环境: CentOS6.8 x86_64 min Heartbeat 3.0.6 http://hg.linux-ha.org/heartbeat-STABLE ...

  2. SpringMVC通过注解获得参数

    SpringMVC可以通过RequestParam注解来映射获得参数,具体用法如下: 例子: 配置过程省略 1.新建controller类 package com.loger.controller; ...

  3. HTML 标记

  4. jquery的animate动画

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  5. scala中java并发编程

    Runnable/Callable 线程(Thread) Executors/ExecutorService Future 线程安全问题 示例:搜索引擎 解决方案 Runnable/Callable ...

  6. 随机数生成类Random用法

    一.构造方法: Random()           创建一个新的随机数生成器. Random(long seed)           使用单个 long 种子创建一个新的随机数生成器. 无参构造方 ...

  7. sublime从官网纯净版到插件完整版

    01.纯净版下载地址:www.sublimetext.com/ 02.下载Package Control插件管理工具,网址:https://packagecontrol.io/ 安装介绍:https: ...

  8. vs2015下载及预览与发布

    VS2015 RC发布下载,通用Windows平台必备神器! 几个月前微软发布了Visual Studio 2015的技术预览版本,之后又先后发布了6个更新版本.如今,微软已在其官方页面中公布了最新开 ...

  9. jquery无法为动态生成的元素添加点击事件的解决方法

    遇到 jquery无法为动态生成的元素添加点击事件,谷歌一下,整理一下解决方法如下: (<li>中间的元素是动态生成的), 现在想为<i>添加点击事件, 例子如下: <d ...

  10. Access denied for user 'root'@'localhost' (using password:YES) 解决方案[转]

    关于昨天下午说的MySQL服务无法启动的问题,解决之后没有进入数据库,就直接关闭了电脑. 今早打开电脑,开始-运行 输入“mysql -uroot -pmyadmin”后出现以下错误: “Access ...