//感觉自己好弱。。。 class Solution { public: void Insert(int num1) { num.push_back(num1); } double GetMedian() { sort(num.begin(),num.end()); if(num.size()%2==1||num.size()==1) return num[num.size()/2]; else return (double(num[num.size()/2-1])+double(num[num.size()/2]))/2; } vector<int>num; };
时间: 2024-10-06 00:57:59