更新 '3.4.cpp'
parent
c5d0f8a433
commit
1b739472e6
19
3.4.cpp
19
3.4.cpp
|
@ -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++)
|
||||
|
|
Reference in New Issue