#include #include using namespace std; double maxelem(istream& f); int main() { ifstream f("input.txt"); if (!f.is_open()) { cerr << "Cannot open an input file." << endl; return (-1); } double y = maxelem(f); f.close(); cout << "Maximal element: " << y << endl; return 0; } double maxelem(istream& f) { double y = -1e30; // -infinity double x; while (f >> x) { if (x > y) y = x; } return y; }