#include #include #include #include using namespace std; class Newton { public: void readFromFile(string filename) { string str; // stopien = 0; fstream file(filename); if (!file) { cerr << "Nie udalo sie otworzyc pliku o nazwie: " << filename << "\n"; exit(EXIT_FAILURE); } while (getline(file, str)) { std::istringstream iss(str); if (iss >> a >> b) { x.push_back(a); y.push_back(b); } } file.close(); } void oblicz() { } void wyswietl_x_y() { for (int i = 0; i < x.size(); i++) { cout << "x" << i << ": " << x[i] << "\t \t" << "y" << i << ": " << y[i] << "\n"; } } void wyswietl_tabela() { std::cout << std::setw(5) << "i" << std::setw(10) << "x" << std::setw(10) << "y" << std::endl; // Table headers std::cout << std::string(26, '-') << std::endl; for (size_t i = 0; i < x.size(); ++i) { std::cout << std::setw(5) << i << std::setw(10) << x[i] << std::setw(10) << y[i] << std::endl; // Table rows } } private: float a, b; vector x ,y; }; int main() { Newton first; first.readFromFile("input.txt"); // first.wyswietl_x_y(); first.wyswietl_tabela(); return 0; }