mattsan #7098(2008/08/11 05:15 GMT) [ C++ ] Rating0/0=0.00
Boost(1.35.0)を使ってどうにかこうにか。
もはやGolfではないです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#include <iostream> #include <string> #include <vector> #include <map> #include <iterator> #include <algorithm> #include <boost/asio.hpp> #include <boost/regex.hpp> using namespace std; using namespace boost; using namespace boost::asio; typedef vector<string> Strings; typedef map<string, vector<int> > Dic; int main() { ip::tcp::iostream src( "www.gnu.org", "http" ); src << "GET /licenses/gpl.txt HTTP/1.0\r\n" << "Host: www.gnu.org\r\n" << "\r\n" << flush; // 読み込み Strings lines; string s; bool body = false; while(getline(src, s)) { if(body) lines.push_back(s); if(s == "\r") body = true; } // 解析 regex re("¥¥w+"); Dic dic; int lineno = 1; for(Strings::const_iterator i = lines.begin(); i != lines.end(); ++i) { sregex_iterator ri(i->begin(), i->end(), re); sregex_iterator end; for(; ri != end; ++ri) { dic[ri->str()].push_back(lineno); } ++lineno; } // 書き出し for(Dic::const_iterator i = dic.begin(); i != dic.end(); ++i) { cout << i->first << ":"; copy(i->second.begin(), i->second.end(), ostream_iterator<int>(cout, ",")); cout << endl; } return 0; }
Rating0/0=0.00-0+
[ reply ]
mattsan
#7098()
[
C++
]
Rating0/0=0.00
Boost(1.35.0)を使ってどうにかこうにか。
もはやGolfではないです。
Rating0/0=0.00-0+
[ reply ]