题目地址:

http://acm.hdu.edu.cn/showproblem.php?pid=2673

拍两次序,交替输出


 #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
#define MAX_NUMBER 10000
bool myfunction1 (int i,int j) { return (i<j); }
bool myfunction2 (int i,int j) { return (i>j); }
int number[][MAX_NUMBER];
int main()
{
//freopen("input.txt","r",stdin);
int n,tmp,count=,index,flag;
while(cin>>n && n!=)
{
for(int i=;i<n;i++)
{
cin>>tmp;
number[][i]=number[][i]=tmp;
}
sort(number[],number[]+n,myfunction1);
sort(number[],number[]+n,myfunction2);
index=count=;
flag=;
while(index<n && count<n)
{
if(flag) cout<<" ";
if(count<n) {cout<<number[][index];count++;}
if(count<n) {cout<<" "<<number[][index];index++;count++;}
flag=;
}
}
return ;
}

[acm]HDOJ 2673 shǎ崽 OrOrOrOrz的更多相关文章

  1. HDU 2673 shǎ崽 OrOrOrOrz

    #include <cstdio> #include <algorithm> using namespace std; int main() { int n; while (s ...

  2. HDU2673:shǎ崽 OrOrOrOrz

    Problem Description Acmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in Inter ...

  3. hdu 1.3.4 shǎ崽 OrOrOrOrz

    简单的排序,注意输出即可 #include <iostream> #include <algorithm> using namespace std; int main() { ...

  4. hdu 2671 shǎ崽 OrOrOrOrz(排序)

    题意:排序后按题目要求输出 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using ...

  5. [acm]HDOJ 2059 龟兔赛跑

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2059 起点和终点,共n+2个点,n+2个状态,简单DP即可. //11512698 2014-08- ...

  6. [acm]HDOJ 1200 To and Fro

    题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1200 简单字符串处理,找规律 /* 11509672 2014-08-21 11:32:55 Acc ...

  7. [acm]HDOJ 2064 汉诺塔III

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2064 汉诺塔变种,只能从中间专业,递归关系为:f(n)=3*f(n-1)+2. //汉诺塔变种,只能 ...

  8. [acm]HDOJ 3082 Simplify The Circuit

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3082 字符串处理+并联电阻公式 //11481261 2014-08-18 16:52:47 Acc ...

  9. hdu-2673-shǎ崽 OrOrOrOrz(水题)

    注意输出格式 #include <iostream> #include <algorithm> using namespace std; +]; int main() { in ...

随机推荐

  1. 点击出现黑色背景的解决:-webkit-tap-highlight-color:rgba(0,0,0,0)

    在手机上(iphone)点击按钮的时候,屏幕总会闪动一下,这让页面看起来很不友好也不流畅.解决方案加了一句css就解决了: -webkit-tap-highlight-color:rgba(0,0,0 ...

  2. jQuery 获取DOM元素

    (function (window){ var arr=[]; var VP=function(selector,context){ return new VP.fn.init(selector,co ...

  3. mybatis性能优化之降低数据库连接

    做性能优化的最重要的功能就是降低数据库的交互.非常多程序猿一般在开发的时候仅仅考虑简单的实现功能,无论业务简单复杂,仅仅要实现即可. mybatis有个重要的功能就是考虑在联合查询时技巧: <? ...

  4. 通俗的理解java的堆和栈

    堆 可以把堆理解为一家餐厅,里面有200张桌子,也就是最多能同时容纳200桌客人就餐,来一批客人就为他们安排一些桌子,如果某天来的客人特别多,超过200桌了,那就不能再接待超出的客人了.当然,进来吃饭 ...

  5. Spring Security 表单登录

    1. 简介 本文将重点介绍使用Spring Security登录. 本文将构建在之前简单的Spring MVC示例之上,因为这是设置Web应用程序和登录机制的必不可少的. 2. Maven 依赖 要将 ...

  6. Chrome自带恐龙小游戏的源码研究(七)

    在上一篇<Chrome自带恐龙小游戏的源码研究(六)>中研究了恐龙的跳跃过程,这一篇研究恐龙与障碍物之间的碰撞检测. 碰撞盒子 游戏中采用的是矩形(非旋转矩形)碰撞.这类碰撞优点是计算比较 ...

  7. redis问题接囧办法及经验

    转自:https://my.oschina.net/freegeek/blog/324410 1.redis持久化,来自官方说明 如何选择使用哪种持久化方式? 一般来说, 如果想达到足以媲美 Post ...

  8. /usr/bin/mysqld_safe_helper: Cannot change uid/gid (errno: 1) (转)

    From: https://www.rootusers.com/how-to-fix-mariadb-10-0-29-selinux-update-failure/ 安装mysql 10.0.29后, ...

  9. IT痴汉的工作现状10-Sprint Planning

    这是我们的第四个Sprint了.因为上一个迭代周期的失利,Leader群发邮件这样描写叙述道:"对任务的乐观预计,导致Sprint 3没有如期完毕. 我们须要在这次Sprint计划中细致评估 ...

  10. Makefile注意点总结

    1 "="和":=" "="号赋值时,如果右边的值里面有未展开的变量,要等到整个Makefile的变量处理完之后,再展开,也就是说,如果该未 ...