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 

InputThere are multiple test cases, each case begins with one integer N(1 <= N <= 10000), following N distinct integers.OutputOutput 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<stdio.h>
#include<algorithm>
using namespace std; int main(){
int a[10000],n,i,j;
while(~scanf("%d",&n)){
for(i=0;i<n;++i)
scanf("%d",&a[i]);
sort(a,a+n);
i=0;//!!
j=n-1;
while(i<j){
printf("%d %d",a[j],a[i]);
if(i+1!=j)printf(" ");
++i;
--j;//从两变填入
}
if(i==j)printf("%d",a[i]);
printf("\n");
}
return 0;
}

  

最新文章

  1. 用github来展示你的前端页面吧
  2. 通过PowerShell启用AADC的密码同步功能
  3. node学习笔记(三)
  4. 数据访问的历史 Windows
  5. c-free
  6. 怎样在EPLAN P8里创建自己想要的电气元件符号
  7. bug_ _ 常见的bug1
  8. Django admin site(二)ModelAdmin methods
  9. configure: error: Cannot find libmysqlclient under /usr Note that the MySQL client library is not bundled anymore! 报错解决
  10. IOS回调机制——代理,通知中心以及Block
  11. 【C/C++】Linux下使用system()函数一定要谨慎
  12. 社群系统ThinkSNS + 移动端研发周报
  13. eclipse中常用提高效率的快捷键
  14. Windows Server2012R2 添加Microsoft .NET Framework 3.5 功能失败的解决方法
  15. windows SSH Tunnel实施日记
  16. 快速理解Token,Cookie,Session
  17. c# 集合去重并筛选
  18. 使用 Infer.NET 进行概率编程
  19. Oracle RAC环境下ASM磁盘组扩容
  20. [读书笔记]Linux命令行与shell编程读书笔记03 文件系统等

热门文章

  1. 【bzoj3052】[wc2013]糖果公园 带修改树上莫队
  2. BZOJ 1023: [SHOI2008]cactus仙人掌图 | 在仙人掌上跑DP
  3. C++——派生类中的访问——可见性问题
  4. POJ2699:The Maximum Number of Strong Kings(枚举+贪心+最大流)
  5. Codeforces Round #525 (Div. 2) F. Ehab and a weird weight formula
  6. saltshaker填坑
  7. linux 端口号、进程id、杀进程、查询tcp的连接(各种状态的)
  8. i=i+1与i+=1的区别及效率(Java)
  9. jw player笔记二----修改logo
  10. netty学习指南