From 47722313e1123040978b967dbe16de6ff42c3503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzysztof=20Feiler?= Date: Thu, 24 Jan 2019 03:36:18 +0100 Subject: [PATCH] zad3 --- asdzes2zad3heron/.gitignore | 73 +++++++++++++++++++++++++++ asdzes2zad3heron/asdzes2zad3heron.pro | 7 +++ asdzes2zad3heron/main.c | 33 ++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 asdzes2zad3heron/.gitignore create mode 100644 asdzes2zad3heron/asdzes2zad3heron.pro create mode 100644 asdzes2zad3heron/main.c diff --git a/asdzes2zad3heron/.gitignore b/asdzes2zad3heron/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/asdzes2zad3heron/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/asdzes2zad3heron/asdzes2zad3heron.pro b/asdzes2zad3heron/asdzes2zad3heron.pro new file mode 100644 index 0000000..8b6e209 --- /dev/null +++ b/asdzes2zad3heron/asdzes2zad3heron.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +CONFIG += console +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += \ + main.c diff --git a/asdzes2zad3heron/main.c b/asdzes2zad3heron/main.c new file mode 100644 index 0000000..51628f9 --- /dev/null +++ b/asdzes2zad3heron/main.c @@ -0,0 +1,33 @@ +#include +#include + +static long long unsigned c; +static long double eps; + +static long double x; +static long long unsigned n; + +int next() +{ + long double p = x; + x = (p + (c / p)) / 2; + n++; + return fabsl(x - p) >= eps; +} + +void print() +{ + printf("x_%llu=%Lf, ", n, x); +} + +int main() +{ + scanf("%llu %Lf", &c, &eps); + x = c; + n = 0; + print(); + while (next()) + print(); + print(); + return 0; +}