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. Android:Asmack能登录但是获取不到联系人的问题

    先说一下:换了N个jar包,换了N个OpenFire,就是获取不到联系人.但是能登录.特别纳闷,百度不到,google一下,有人隐约说了下权限的问题. 终于搞出来了,总结一下,浪费了一整天的时间.(码 ...

  2. JavaScript input框输入实时校验

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  3. JQery之Ajax

    $.ajax({ url:'/comm/test1.php', type:'POST', //GET async:true, //或false,是否异步 data:{ name:'yang',age: ...

  4. Jira 6.0.3安装破解汉化

    前段时间和上海的朋友交流了下,他们公司使用JIRA管理项目.回来整理了下感觉很不错. http://www.unlimax.com/jira.html工作中总是有各种事务要去处理,而这些事务不仅仅是代 ...

  5. html5权威指南:标记文字、组织内容、文档分节

    HTML5新增及删除标签:http://www.cnblogs.com/starof/archive/2015/06/23/4581850.html 第八章:标记文字                 ...

  6. 2016年团体程序设计天梯赛-决赛 L1-2. I Love GPLT(5)

    这道超级简单的题目没有任何输入. 你只需要把这句很重要的话 —— “I Love GPLT”——竖着输出就可以了. 所谓“竖着输出”,是指每个字符占一行(包括空格),即每行只能有1个字符和回车. #i ...

  7. el表达式跟ognl表达式的区别

    :  EL表达式 单纯在jsp页面中出现,是在四个作用域中取值,page,request,session,application. 如果在struts环境中,它除了有在上面的四个作用域的取值功能外,还 ...

  8. Maxmum subsequence sum problem

    We have a lot of ways to solve the maximum subsequence sum problem, but different ways take differen ...

  9. Objetive-C 中的相等比较

    1.== 用于比较两个对象的地址是否相同 1)需要注意的是相同的短字符串,一定大小整数(nsnumber),Objetive-C 底层会做cache,两个对象,指向同一个地址. 例如: NSStrin ...

  10. [ An Ac a Day ^_^ ] CodeForces 339A Helpful Maths

    熄灯了才想起来没写博客 赶紧水一道题碎觉…… #include<stdio.h> #include<iostream> #include<algorithm> #i ...