/* User ID: tanmoyt1 Link : http://train.usaco.org/usacoprob2?a=z9TmPNj3S8H&S=namenum */ /* PROG: namenum LANG: C++ */ #include <iostream> #include <fstream> #include <string> using namespace std; string serializeName(const string &in) { string ret = ""; for(int i = 0; i < in.length(); ++i) { if(in[i] == 'Q' || in[i] == 'Z') return "1"; if(in[i] < 'Q') ret += ((in[i] - 'A') / 3) + '2'; else ret += ((in[i] - 'Q') / 3) + '7'; } return ret; } int main() { freopen("namenum.in","r",stdin); freopen("namenum.out","w",stdout); ifstream fdict ("dict.txt"); string serial; cin >> serial; bool found = false; string entry; while(fdict >> entry) if(entry.length() == serial.length() && serializeName(entry) == serial) { found = true; cout << entry << endl; } if(!found) cout << "NONE" << endl; return 0; }
(fdict >> entry) what this line do plz ?
fdict is an object of ifstream class. This C++ class deals with input output from file. In this code the object fdict is taking entry form dict.txt file and inserting them into a string called entry.