#include #include #include using namespace std; int main() { ifstream elf; elf.open("elements.txt"); if (elf.fail()) { cout << "Can't open the file\n"; exit(1); } ofstream outf; outf.open("new.txt"); int pos = 1; while (true) { string symbol, name; double atwt; elf >> symbol >> name >> atwt; if (elf.fail()) break; outf << symbol << " " << name << " " << pos << " " << atwt << "\n"; pos += 1; } cout << "All done\n"; elf.close(); outf.close(); }