杭电OJ 题 2673 shǎ崽 OrOrOrOrz 解题报告
来源:互联网 发布:男女对唱的网络歌曲 编辑:程序博客网 时间:2024/05/30 02:23
shǎ崽 OrOrOrOrz
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4485 Accepted Submission(s): 2141
Total Submission(s): 4485 Accepted Submission(s): 2141
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
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
51 2 3 4 5
Sample Output
5 1 4 2 3
——————————————————————————————————————————————————————————————
简单的排序,输出从两边输出, 我是用快排进行排序的
简单的排序,输出从两边输出, 我是用快排进行排序的
/************************ 程序名:shǎ崽 OrOrOrOrz.c* 功能:ACM************************/#include <stdio.h>void QuickSort(int *, int, int);int Process(int *, int, int);int main(){ int N, i, j; int array[11111]; while(scanf("%d", &N) != EOF) { for(i = 0; i < N; i++) { scanf("%d", array + i); } QuickSort(array, 0, N-1); i = 0; j = N-1; while(i < j) { printf("%d ", array[j]); printf("%d", array[i]); i++; j--; if(i < j || N % 2) { printf(" "); } } if(N % 2) { printf("%d", array[i]); } printf("\n"); } return 0;}void QuickSort(int *array, int i, int j){ int k; if(i < j) { k = Process(array, i, j); QuickSort(array, i, k-1); QuickSort(array, k+1, j); }}int Process(int *array, int i, int j){ int x; x = array[i]; while(i < j) { while(array[j] >= x && i < j) { j--; } array[i] = array[j]; while(array[i] <= x && i < j) { i++; } array[j] = array[i]; } array[i] = x; return i;}
- 杭电OJ 题 2673 shǎ崽 OrOrOrOrz 解题报告
- 杭电2673 shǎ崽 OrOrOrOrz
- 杭电 acm shǎ崽 OrOrOrOrz
- 杭电2673(shǎ崽 OrOrOrOrz)
- 2673 shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz
- HDU 2673 shǎ崽 OrOrOrOrz
- hdu 2673 shǎ崽 OrOrOrOrz
- hdu 2673 shǎ崽 OrOrOrOrz
- HDU 2673:shǎ崽 OrOrOrOrz
- HDU 2673 shǎ崽 OrOrOrOrz (排序)
- hdoj-2673-shǎ崽 OrOrOrOrz
- Hdoj 2673 shǎ崽 OrOrOrOrz
- shǎ崽 OrOrOrOrz hdu2673
- HDU2673:shǎ崽 OrOrOrOrz
- HDU shǎ崽 OrOrOrOrz
- Hacking Tut Running MapleStory on Vmware
- HDOJ2043 密码
- 模块加载
- SQLite数据库增删改查操作
- Java邮件开发-----JavaMail(一)
- 杭电OJ 题 2673 shǎ崽 OrOrOrOrz 解题报告
- 熟悉struts2MVC模式之用模型驱动传参的例子
- 【Boost】boost::to_upper_copy详解
- 陶醉在音乐的国度,我如痴如醉
- 12-12-09记录
- Hdu 1423 Greatest Common Increasing Subsequence
- 杨辉三角
- iOS开发之使用lipo命令制作模拟器与真机通用静态库
- Servlet的几种跳转