zoukankan      html  css  js  c++  java
  • [acm]HDOJ 2673 shǎ崽 OrOrOrOrz

    题目地址:

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

    拍两次序,交替输出


     1 #include<iostream>
     2 #include<algorithm>
     3 #include<cstdio>
     4 using namespace std;
     5 #define MAX_NUMBER 10000
     6 bool myfunction1 (int i,int j) { return (i<j); }
     7 bool myfunction2 (int i,int j) { return (i>j); }
     8 int number[2][MAX_NUMBER];
     9 int main()
    10 {
    11     //freopen("input.txt","r",stdin);
    12     int n,tmp,count=0,index,flag;
    13     while(cin>>n && n!=0)
    14     {
    15         for(int i=0;i<n;i++)
    16         {
    17             cin>>tmp;
    18             number[0][i]=number[1][i]=tmp;
    19         }
    20         sort(number[0],number[0]+n,myfunction1);
    21         sort(number[1],number[1]+n,myfunction2);
    22         index=count=0;
    23         flag=0;
    24         while(index<n && count<n)
    25         {
    26             if(flag) cout<<" ";
    27             if(count<n) {cout<<number[1][index];count++;}
    28             if(count<n) {cout<<" "<<number[0][index];index++;count++;}
    29             flag=1;
    30         }
    31     }
    32     return 0;
    33 }
  • 相关阅读:
    List三个子类的特点
    三种迭代是否可以删除
    Vector
    LinkedList
    ArrayList
    ListIterator
    ConcurrentModificationException并发修改异常
    List
    Collection
    数组转换成集合
  • 原文地址:https://www.cnblogs.com/panweishadow/p/3926877.html
Copyright © 2011-2022 走看看