From 1b739472e6a80e310efd2e76e74a4f7f6f6329ff Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Sun, 17 Sep 2017 21:17:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'3.4.cpp'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3.4.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/3.4.cpp b/3.4.cpp index fc26882..a35e71f 100644 --- a/3.4.cpp +++ b/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> vec; for(const auto& pr:mp) @@ -65,6 +83,7 @@ int main() ofstream ofs("result/3.4.csv"); #define cout ofs + cout<<"职位,需求量"<