From 713253346e85585c2708839a6597cfd99b6b03ec Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Tue, 12 Sep 2017 16:02:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'3.6.cpp'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3.6.cpp | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 3.6.cpp diff --git a/3.6.cpp b/3.6.cpp new file mode 100644 index 0000000..257ca5a --- /dev/null +++ b/3.6.cpp @@ -0,0 +1,193 @@ +#include "MySQLWrapper.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +#include "local_db_account.h" +#include "util.hpp" + +int main() +{ + /// 3.6 计算机专业不同编程语言平均薪资柱状图. Based on 3.5 code. + + MySQLConn conn; + conn.connect("127.0.0.1",db_user,db_passwd,"bigdata3",3306); + cout<<"Connected to DB"<> langs + { + { "Java" }, + { "C++" }, + { "C#" }, + { "Python", "Py" }, + { "PHP" } , + { "Javascript", "JS" }, + { "Swift" }, + { "Ruby" }, + { "Perl" }, + { "Visual Basic","VisualBasic","VB" }, + { "Go" }, + { "MATLAB" } + }; + + map mp; + + int szLang=langs.size(); + for(int i=0;isecond += cc; + } + else + { + mp.insert(make_pair(langs[i][0],cc)); + } + }); + }); + }; + + conn.exec("use bigdata3",nullptr); + fn1(sqlcmd); + + ostr.str(""); + ostr<<"select count(*) from pages where ((title like '%" + <> vec; + vec.insert(vec.end(),mp.begin(),mp.end()); /// ??? Not Naive Code? + sort(vec.begin(),vec.end(),[](const pair& a,const pair& b) + { + return a.second > b.second; + }); + + /// ----------- Above : 3.5 -------------- + /// ----------- Below : 3.6 -------------- + + auto fn_getindex=[&](const string& LangMainLable) + { + int sz=langs.size(); + for(int i=0;i> cashmp; + + int szLoop=min(10u,vec.size()); + for(int i=0;i& vecref=cashmp[vec[i].first]; + int szVec=vecref.size(); + for(const auto& ky:vecref) + { + avLow+=ky.low; + avHigh+=ky.high; + } + + if(szVec!=0) + { + avLow/=szVec; + avHigh/=szVec; + avMid=(avLow+avHigh)/2; + } + + cout<