zoukankan      html  css  js  c++  java
  • 杭电2673--shǎ崽 OrOrOrOrz

    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:  2672 2674 2668 1040 1236 
     1 #include <cstdio>
     2 #include <iostream>
     3 #include <algorithm>
     4 #include <cstring>
     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
    ", num[n/2]);
    20         }
    21         else
    22         {
    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                 else
    28                     printf(" %d %d", num[i], num[j]);
    29             }
    30             printf("
    ");
    31         }
    32     }
    33     
    34     return 0;
    35 }
  • 相关阅读:
    Memcache
    在.net中读写config文件的各种方法
    Visual Studio 2013 Web开发、新增功能:“Browser Link”
    Web.Config文件中使用configSource
    方正S4101g笔记本电脑搜不到无线网络
    *.bz2和*.gz分别是什么压缩格式
    HTTP 错误 500.19
    【Java】得到当前股票信息
    【Java】得到当前系统时间,精确到毫秒
    【Java】SHA加密
  • 原文地址:https://www.cnblogs.com/soTired/p/4725053.html
Copyright © 2011-2022 走看看