diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a4a118 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.out diff --git a/CMakeLists.txt b/horner/CMakeLists.txt similarity index 100% rename from CMakeLists.txt rename to horner/CMakeLists.txt diff --git a/dane.txt b/horner/dane.txt similarity index 100% rename from dane.txt rename to horner/dane.txt diff --git a/horner_class.cpp b/horner/horner_class.cpp similarity index 100% rename from horner_class.cpp rename to horner/horner_class.cpp diff --git a/horner_simple.cpp b/horner/horner_simple.cpp similarity index 100% rename from horner_simple.cpp rename to horner/horner_simple.cpp diff --git a/newton/input.txt b/newton/input.txt new file mode 100644 index 0000000..209ee0e --- /dev/null +++ b/newton/input.txt @@ -0,0 +1,4 @@ +1 2 +1.5 2.5 +2 3.5 +2.5 4 \ No newline at end of file diff --git a/newton/main.cpp b/newton/main.cpp new file mode 100644 index 0000000..9641500 --- /dev/null +++ b/newton/main.cpp @@ -0,0 +1,69 @@ +#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; +} \ No newline at end of file