Hdu2673:shǎ Cub Ororororz

Source: Internet
Author: User

Problem Descriptionacmer in HDU-ACM team is ambitious, especially shǎ cub, he can spend time in Internet bar doing problems Overnight. So many girls want to meet and Orz him. But Orz him are not so 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 and then SM Allest, then second biggest, second smallest etc. Until all the numbers was chosen. For example, give your 1 2 3 4 5, you should output 5 1 4 2 3 inputthere is multiple test cases, each case begins with one Integer n (1 <= n <= 10000), following n distinct integers. Outputoutput a sequence of distinct integers described above. Sample INPUT5 1 2 3 4 5 Sample OUTPUT5 1 4 2 3//flood problem. But pay attention to the format
1#include <iostream>2#include <cstdio>3#include <algorithm>4 5 using namespacestd;6 7 intMain ()8 {9     intn,i;Ten     intdata[10005]; One      while(cin>>N) A     { -          for(i=1; i<=n;i++) -scanf"%d",&data[i]); theSort (data+1, data+1+n); -         if(n%2==0)//an even number of 4/2=2 4 1 3 2 -         { -              for(i=n;i>n/2+1; i--) +cout<<data[i]<<" "<<data[n-i+1]<<" "; -cout<<data[i]<<" "<<data[n-i+1]<<endl;//otherwise PE +         } A         Else//There are odd numbers of 5/2=2 5 1 4 2 3 at         { -              for(i=n;i>n/2+1; i--) -cout<<data[i]<<" "<<data[n-i+1]<<" "; -cout<<data[n/2+1]<<Endl; -         } -  in  -     } to     return 0; +}

Hdu2673:shǎ Cub Ororororz

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.