博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电2673--shǎ崽 OrOrOrOrz
阅读量:5924 次
发布时间:2019-06-19

本文共 1950 字,大约阅读时间需要 6 分钟。

shǎ崽 OrOrOrOrz

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 7821    Accepted Submission(s): 3735

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
 

 

Author
WhereIsHeroFrom
 

 

Source

 

 

 

Recommend
lcy   |   We have carefully selected several similar problems for you:            
1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 int num[10010]; 7 int main() 8 { 9 int n;10 while(~scanf("%d", &n))11 {12 for(int i = 0; i < n; i++)13 scanf("%d", &num[i]);14 sort(num, num + n);15 if(n & 1)16 {17 for(int j = 0, i = n-1; i > n/2; j++, i--)18 printf("%d %d ", num[i], num[j]);19 printf("%d\n", num[n/2]);20 }21 else22 {23 for(int j = 0, i = n-1; i >= n/2; j++, i--)24 {25 if(j == 0)26 printf("%d %d", num[i], num[j]);27 else28 printf(" %d %d", num[i], num[j]);29 }30 printf("\n");31 }32 }33 34 return 0;35 }

 

转载于:https://www.cnblogs.com/soTired/p/4725053.html

你可能感兴趣的文章
分布式--Spring Boot 微服务框架
查看>>
关于FileZilla上传文件后服务器端文件与本地文件大小不一致的解决方法
查看>>
手写SpringMVC实战,一切从Spring底层源码分析开始
查看>>
Spring源码---BeanFactory的抽象
查看>>
XWiki 11.1 发布,协作式应用开发平台
查看>>
创建云数据库HybridDB for MySQL结果表
查看>>
关于SQL+NoSQL : NewSQL数据库
查看>>
从零开始一起学习SLAM | 相机成像模型
查看>>
一个老程序员的忠告:不要一辈子靠技术生存
查看>>
数据类型之间运算关系
查看>>
跳出面向对象思想(二) 多态
查看>>
WebStorm Exception: ...requested without authorization...
查看>>
Jenkins +selenium(学习笔记三十一)
查看>>
k8s使用ServiceAccount Token的方式访问apiserver
查看>>
C语言中用于计算数组长度的函数 “strlen() ”。
查看>>
微信公众平台中临时二维码的scene_id为32位非0整型
查看>>
《快学 Go 语言》第 5 课 —— 神奇的切片
查看>>
eclipse 导入maven项目 不识别web
查看>>
Java入门—集合
查看>>
Go基础语法(四)
查看>>