From 670bd0b219701672643c44773d37ca81d521beba Mon Sep 17 00:00:00 2001 From: dm1sh Date: Sun, 14 Feb 2021 00:02:36 +0500 Subject: [PATCH] Improved and renamed simple card --- 18/1.cpp | 7 ------- 18/{2.py => 29.py} | 0 18/36.cpp | 34 ++++++++++++++++++++++++++++++++++ 18/{3.py => 36.py} | 4 ++-- 18/{4.py => 84.py} | 0 5 files changed, 36 insertions(+), 9 deletions(-) delete mode 100644 18/1.cpp rename 18/{2.py => 29.py} (100%) create mode 100644 18/36.cpp rename 18/{3.py => 36.py} (93%) rename 18/{4.py => 84.py} (100%) diff --git a/18/1.cpp b/18/1.cpp deleted file mode 100644 index 5aba67b..0000000 --- a/18/1.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std; - -int main() -{ -} \ No newline at end of file diff --git a/18/2.py b/18/29.py similarity index 100% rename from 18/2.py rename to 18/29.py diff --git a/18/36.cpp b/18/36.cpp new file mode 100644 index 0000000..8604c0d --- /dev/null +++ b/18/36.cpp @@ -0,0 +1,34 @@ +#include +#include + +using namespace std; + +int main() +{ + ifstream inp("dat/18-17.txt"); + + double p = INT8_MAX; + double msum = INT8_MIN; + double sum = 0; + + while (!inp.eof()) + { + double n; + inp >> n; + + if (n < p) + { + sum += n; + if (sum > msum) + msum = sum; + } + else + sum = 0; + + p = n; + } + + cout << (int)msum << endl; + + return 0; +} \ No newline at end of file diff --git a/18/3.py b/18/36.py similarity index 93% rename from 18/3.py rename to 18/36.py index 489a0c7..0f913af 100644 --- a/18/3.py +++ b/18/36.py @@ -9,10 +9,10 @@ with open('./dat/18-17.txt', 'r') as f: n = float(sn) if n < p: s += n - else: if s > ms: ms = s + else: s = 0 p = n -print(int(ms)) +print(ms) diff --git a/18/4.py b/18/84.py similarity index 100% rename from 18/4.py rename to 18/84.py