[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 }

[acm]HDOJ 2673 shǎ崽 OrOrOrOrz

时间: 2024-11-05 20:34:52

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

hdu 1.3.4 shǎ崽 OrOrOrOrz

简单的排序,注意输出即可 #include <iostream> #include <algorithm> using namespace std; int main() { int a[10001]; int n,i; //int t = 0; while(cin>>n) { //if(t)cout<<endl; //t++; for(i=0; i<n; i++) { cin>>a[i]; } sort(a,a+n); if(n%2==1

HDU2673:shǎ崽 OrOrOrOrz

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

hdu 2671 shǎ崽 OrOrOrOrz(排序)

题意:排序后按题目要求输出 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; int main(){ int a[10000],n,i,j; while(~scanf("%d",&n)){ for(i=0;i<n;++i) scanf("%d",&a[i]); sort(a,a+n); i=0

杭电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

[acm]HDOJ 2064 汉诺塔III

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2064 汉诺塔变种,只能从中间专业,递归关系为:f(n)=3*f(n-1)+2. 1 //汉诺塔变种,只能从中间转移 2 //11485816 2014-08-19 08:44:47 Accepted 2064 0MS 368K 307 B G++ 空信高手 3 #include<iostream> 4 #include<cstdio> 5 using namespace std; 6

[acm]HDOJ 2059 龟兔赛跑

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2059 起点和终点,共n+2个点,n+2个状态,简单DP即可. 1 //11512698 2014-08-21 17:11:55 Accepted 2059 2 //62MS 368K 969 B G++ 空信高手 3 //起点和终点,共n+2个点,n+2个状态,简单DP即可 4 #include<iostream> 5 #include<cstdio> 6 using namespa

[acm]HDOJ 3082 Simplify The Circuit

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3082 字符串处理+并联电阻公式 1 //11481261 2014-08-18 16:52:47 Accepted 3082 0MS 384K 733 B G++ 空信高手 2 #include<string> 3 #include<iostream> 4 #include<cstdio> 5 #include<cstdlib> 6 7 using names

[acm]HDOJ 1200 To and Fro

题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1200 简单字符串处理,找规律 1 /* 2 11509672 2014-08-21 11:32:55 Accepted 3 1200 0MS 380K 442 B G++ 空信高手 4 */ 5 #include<iostream> 6 #include<string> 7 #include<cstdio> 8 using namespace std; 9 int mai

acm hdoj 1157

Who's in the Middle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3136 Accepted Submission(s): 1171   Problem Description FJ is surveying his herd to find the most average cow. He wants to know