Improved and renamed simple card
This commit is contained in:
parent
06c63d6403
commit
670bd0b219
34
18/36.cpp
Normal file
34
18/36.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
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;
|
||||
}
|
@ -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)
|
Loading…
x
Reference in New Issue
Block a user