#include #include #include #include #include #include #include using namespace std; class Phone_Number { public: Phone_Number(string nr) : country(), number() { string::iterator it = nr.begin(); while ( it != nr.end() ) { if ( *it == '+' || isdigit(*it) ) ++it; else it = nr.erase(it); } if ( nr.at(0) == '+' ) { country = nr.substr(1,2); nr = nr.substr(3); } number = nr; } bool operator==(Phone_Number const& other) const { if ( country.size() == 0 || other.country.size() == 0 ) return number == other.number; else return country == other.country && number == other.number; } void print() { cout << country << ":" << number << endl; } private: string country; string number; }; int main() { ifstream ifs("../given_files/do_not_answer.txt"); if ( ! ifs ) { cerr << "Error: blocklist could not be opened." << endl; return 1; } vector v; string number; while ( getline( ifs, number) ) { v.push_back( Phone_Number(number) ); } cout << "Enter one phone number per line (finish by Ctrl-D):" << endl; while ( getline(cin, number) ) { if ( find(v.cbegin(), v.cend(), number) == v.end() ) cout << "This might be okay" << endl; else cout << "Blocked." << endl; } return 0; }