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. KVM下windows虚拟机使用virtio驱动

    KVM下windows虚拟机默认disk使用的是Qemu IDE硬盘,网卡默认是rtl8139网卡.为了使kvm主机在相同的配置下,有更好的效率,可以将网卡和磁盘替换成virtio的驱动. windo ...

  2. (十)foreac遍历、break和countinue以及标签和switch循环

    foreach语法,表示不必创建int变量去对由访问项构成的序列进行计数,foreach将自动产生每一项. 例:输出数组的所有元素. float f[]=new float[5]; f[0]=1.0f ...

  3. angularjs表单中enter键提交

    html页面: <form class="smart-form" id="checkout-form" searchinput> <div c ...

  4. 微信小程序官方demo学习

    最近微信小程序很火,很喜欢那种轻应用,用完就走的理念.于是,下载好微信开发者工具,学习一下官方demo. 体验下来,有类似react和vue的感觉,dom类似react那种组件的,data-bindi ...

  5. CodeForces 703B Mishka and trip

    简单题. 先把环上的贡献都计算好.然后再计算每一个$capital$ $city$额外做出的贡献值. 假设$A$城市为$capital$ $city$,那么$A$城市做出的额外贡献:$A$城市左边城市 ...

  6. CSU 1650 影魔大战

    简单题. 首先判断两个圆是否都与坐标轴相交,有一个不相交直接输出NO 剩下的情况都是相交的.让算一算四个交点.最后只有四种情况了. #include<cstdio> #include< ...

  7. USACO 1.3 Ski Course Design

    Ski Course Design Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer ...

  8. L3-004. 肿瘤诊断

    L3-004. 肿瘤诊断 题目链接:https://www.patest.cn/contests/gplt/L3-004 BFS 之前尝试使用递归dfs,提交后发现有两个段错误,发现递归层数太多,然后 ...

  9. 去掉matlab图片空白边缘

    在图形文件figure的菜单上点击file->export setup size选项中,对"expand axes to fill figure"选项打勾,如下图:

  10. ****ural 1141. RSA Attack(RSA加密,扩展欧几里得算法)

    1141. RSA Attack Time limit: 1.0 secondMemory limit: 64 MB The RSA problem is the following: given a ...