#include #include double maxSum(FILE* f); int main() { FILE* in = fopen("input.txt", "r"); if (in == NULL) { perror("Could not open input file"); return (-1); } double s = maxSum(in); fclose(in); FILE* out = fopen("output.txt", "w"); if (in == NULL) { perror("Could not open output file"); return (-1); } fprintf(out, "%f\n", s); fclose(out); return 0; } double maxSum(FILE* f) { double s = -1e+30; // -infinity double s1 = -1e+30; double a; while (fscanf(f, "%lf", &a) == 1) { if (s1 < 0.) { s1 = a; } else { s1 += a; } if (s < s1) s = s1; } return s; }