更新 '3.4.cpp'

master
Kirigaya Kazuto 2017-09-17 21:17:08 +08:00
parent c5d0f8a433
commit 1b739472e6
1 changed files with 19 additions and 0 deletions

19
3.4.cpp
View File

@ -51,6 +51,24 @@ int main()
});
});
conn.exec("use bigdata2",nullptr);
conn.exec("select title,count(*) from pages where title like '%大数据%' group by title",[&](MySQLResult& res)
{
res.stepRow([&](char** val,unsigned long* len)
{
string title(val[0]);
auto iter=mp.find(Trim(title));
if(iter!=mp.end())
{
iter->second += ParseInt(val[1]);
}
else
{
mp.insert(make_pair(Trim(title),ParseInt(val[1])));
}
});
});
vector<pair<string,int>> vec;
for(const auto& pr:mp)
@ -65,6 +83,7 @@ int main()
ofstream ofs("result/3.4.csv");
#define cout ofs
cout<<"职位,需求量"<<endl;
int szVec=vec.size();
int maxLoop=min(szVec,10);
for(int i=0;i<maxLoop;i++)