#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>

static const char* filename = "roman2.txt";

typedef std::vector<std::string> stringv;

namespace stv {
    stringv& split( stringv& v, std::string& src, char delim = ','){
        std::istringstream iss(src);
        std::string temp;
        while( std::getline(iss,temp,delim) ){
            v.push_back(temp);
        }
    }

    stringv split( std::string& src, char delim = ','){
        stringv lv;
        return split(lv,src,delim);
    }

    template <typename value_type>
    struct joinf {
        value_type& val_;
        value_type& delim_;
        joinf( value_type& val, value_type& delim ) : val_(val), delim_(delim) {}
        void operator ()( value_type& val ){ val_ += ( val + delim_ ); }
    };

    std::string& join( std::string& s, stringv& v, const char* delim = ", "){
        std::string sdelim(delim);
        joinf<std::string> j(s,sdelim);
        std::for_each(v.begin(),v.end(), j);
        return j.val_;
        
    }

    std::string join( stringv& v, const char* delim = ", "){
        std::string lv;
        return join(lv,v,delim);
    }
}

int main(void)
{
    using namespace std;

    cout << "郵便番号を入力してください" << endl;

    string bango; cin >> bango;

    ifstream ifs( filename, ios::in );

    if( ifs.fail() ){
        cout << "ファイルを開けませんでした。:" << filename << endl;
        return 0;
    }

    stringv v;
    string temp;
    bool found = false;
    while( !found && std::getline(ifs,temp) ){
        v.clear();
        stv::split(v,temp,'\t');
        found = ( v.at(1) == bango );
    }
    ifs.close();
    
    cout << ( found ? stv::join(v,", ") : "見つかりませんでした。" )
         << endl;
    return 0;
}
