summaryrefslogtreecommitdiff
path: root/math/maxTeilfeld.cpp
diff options
context:
space:
mode:
authorPaul Jungeblut <s_jungeb@i08pc55.atis-stud.uni-karlsruhe.de>2014-11-24 15:16:57 +0100
committerPaul Jungeblut <s_jungeb@i08pc55.atis-stud.uni-karlsruhe.de>2014-11-24 15:16:57 +0100
commitf201d8cbb514802529d9a2f3024a258600d46aaa (patch)
treed0f00c412934c067f3e9e179e590924f5121a3ef /math/maxTeilfeld.cpp
parent8be73d5d2f24721795991badfb3cfe5eb551beb8 (diff)
max Teilfeld und to-do-liste
Diffstat (limited to 'math/maxTeilfeld.cpp')
-rw-r--r--math/maxTeilfeld.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/math/maxTeilfeld.cpp b/math/maxTeilfeld.cpp
new file mode 100644
index 0000000..2b732bb
--- /dev/null
+++ b/math/maxTeilfeld.cpp
@@ -0,0 +1,14 @@
+//N := length of field
+int maxStart = 1, maxLen = 0, curStart = 1, len = 0;
+double maxValue = 0, sum = 0;
+for (int pos = 0; pos < N; pos++) {
+ sum += values[pos];
+ len++;
+ if (sum > maxValue) { // neues Maximum
+ maxValue = sum; maxStart = curStart; maxLen = len;
+ }
+ if (sum < 0) { // alles zuruecksetzen
+ curStart = pos +2; len = 0; sum = 0;
+ }
+}
+//maxSum := maximaler Wert, maxStart := Startposition, maxLen := Laenge der Sequenz \ No newline at end of file