标签:style blog color os io ar 2014 div
/******************************************************************** @file Main_practise.cpp @date 2014-8-22 @author Tiger @brief What is the Median? ********************************************************************/ #include <cstdio> #include <vector> #include <algorithm> //#define OJ void Insert(std::vector<int>& vec, int nNum); int main(int argc, const char* argv[]) { #ifdef OJ freopen("input.txt", "r", stdin); #endif std::vector<int> vec; int nNum = 0; while (scanf("%d", &nNum) != EOF) { vec.push_back(nNum); sort(vec.begin(), vec.end()); int nPos = vec.size()/2; if ((vec.size() & 1) == 1) { printf("%d\n", vec.at(nPos)); } else { printf("%d\n", (vec.at(nPos-1)+vec.at(nPos))/2); } } return 0; }
标签:style blog color os io ar 2014 div
原文地址:http://www.cnblogs.com/roronoa-zoro-zrh/p/3928529.html