#3318: C++錯在哪呢?


justin (justin)

學校 : 不指定學校
編號 : 10739
來源 : [1.162.92.57]
最後登入時間 :
2014-06-08 16:45:19
c010. 10107 - What is the Median? -- UVa10107 | From: [114.36.53.112] | 發表日期 : 2010-01-24 13:21

 測資跑出來都是對的耶

 但都是OLE

#include<iostream>
#define n 10000
using namespace std;
int main()
{
    int s[n],a,b,holder,j;
    a=1;
    while(1)
    {
            if(cin.eof())break;
            cin>>s[a];
            holder=s[a];
            j=a-1;
            while(j>0)
            {
                      if(holder <  s[j])
                      {
                            s[j+1]=s[j];
                            j--;
                            
                      }

                      else
                      {
                          break;
                      }          
            }
            s[j+1]=holder;
            if(a%2==1)
            {
                      cout<<s[(a+1)/2]<<endl;
            }
            else
            {
                      cout<<(s[a/2]+s[a/2+1])/2<<endl;
            }
            a++;
           
    }
   // return 0
;    
}

 
ZeroJudge Forum