题目地址:

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. SAS连接MYSQL的步骤及引用数据表

    1.建立逻辑库 libname  dz  ’物理路径'; 2.逻辑库做为桥梁连接SAS与MYSQL libname dz MYSQL USER=*****  PASSWORD=****  DATABA ...

  2. Leetcode Array 11 Container With Most Water

    题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...

  3. 深入浅出Attribute (一)

    正文: 什么是Attribute?Attribute是干什么使的?Attribute与Property到底有什么区别?…… 长久以来,这些问题一直困扰着并不怎么广大的C#初学者.原因大概有两个,一是A ...

  4. 摩托罗拉SE955 One Discrete Length,Two Discrete Lengths,Length Within Range 相关解释

    motorola scanner datasheet相关解释(下面通过Simple Serial Interface(SSI)进行设置,非扫描官方datasheet的设置条码): One Discre ...

  5. 关于erlang的-run 的启动参数

    在github上,关于erlang的一致性hash,有erlang-ryng和 hash_ring .在这里先聊下erlang-ryng这个. 在erlang-ryng的启动方式上,github上提供 ...

  6. android 在githup中的资源整理(转)

    1.Github开源Android组件资源整理(一) 个性化控件(View) 2.Github开源Android组件资源整理(二)ActionBar和Menu 3. Github开源Android组件 ...

  7. phpmyadmin内存溢出

    phpmyadmin Fatal error: Allowed memory size of 134217728 bytes 解决方法: 在报错的页面里,加上这句: ini_set('memory_l ...

  8. java jdbc 同时操作查询删除操作

    Connection conn = null;        try {            // 创建连接实例            conn = JdbcUtility.GetFactory() ...

  9. Java知识点梳理——常用方法总结

    1.查找字符串最后一次出现的位置 String str = "my name is zzw"; int lastIndex = str.lastIndexOf("zzw& ...

  10. python 基础 4.5 用函数实现九九乘法表

    #/usr/bin/python #coding=utf-8 #@Time   :2017/11/3 10:44 #@Auther :liuzhenchuan #@File   :用函数实现九九乘法口 ...