Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Stock buy/sell
#include <iostream> #include <vector> #include <stdio.h> using namespace std; void stock() { double values[8] = { 1.39, 1.23, 115.29, -20.59, -21.58, -25.53, -20.45, 199.24 }; double maxDiff = -1000; double diff = 0; double bottom = values[0]; int begin, begin_tmp, end; for (int i = 1; i < 8; i++) { diff += values[i] - values[i - 1]; if (diff > maxDiff) { maxDiff = diff; begin = begin_tmp; end = i; } if (values[i] < bottom) { bottom = values[i]; diff = 0; begin_tmp = i; } } cout << maxDiff << endl; cout << begin << " " << end; } int main() { stock(); }
run
|
edit
|
history
|
help
0
Discounting
kickstartd
finding factor
Procesos estocasticos Beta 2.0
Hello
Dejalo a la Suerte
Member function detection
Test 9(2020)
Graph Theory 2
InverseMatrix2n2