#include "library.h" struct element { string symbol, name; int atno; double atwt; }; void print(element e) { cout << e.symbol << ", " << e.name << ", number = " << e.atno << ", atomic weight = " << e.atwt << "\n"; } void main() { element table[110]; ifstream fi("table.txt"); int n = 1; while (true) { string sym, name; double wt; fi >> sym >> name >> wt; if (fi.fail()) break; cout << n << " " << sym << " " << name << " " << wt << "\n"; table[n].symbol = sym; table[n].name = name; table[n].atno = n; table[n].atwt = wt; n += 1; } n -= 1; fi.close(); cout << n << " elements read\n"; cout << "Enter -1 to stop - "; while (true) { int a; cout << "Enter atomic number: "; cin >> a; if (a == -1) break; if (a < 1 || a > n) { cout << "bad number\n"; continue; } print(table[a]); } cout << "Bye then.\n"; }