#include #include #include using namespace std; struct element { int atno; string name, sym; double atwt; }; int read_table(element table[]) { ifstream ef("/home/www/class/een118/a3010b.txt"); if (ef.fail()) { cout << "Can't read file\n"; exit(1); } int i = 0; while (true) { string n, s; double w; ef >> s >> n >> w; if (ef.fail()) break; i += 1; table[i].sym = s; table[i].name = n; table[i].atwt = w; table[i].atno = i; } ef.close(); return i; } /* You may prefer this version of the body of the loop. { ef >> table[i+1].sym >> table[i+1].name >> table[i+1].atwt; if (ef.fail()) break; i += 1; table[i].atno = i; } */ int main() { element table[120]; int num_els = read_table(table); while (true) { int x; cin >> x; cout << table[x].sym << " " << table[x].name << "\n"; } }