Answered step by step
Verified Expert Solution
Question
1 Approved Answer
can you please implement this code: into this code MaxSubSum.cpp: #include #include #include using namespace std; vector max_subseq_sum_alg4_collect(const vector &, int&); void print_vector(const vector &);
can you please implement this code:
into this code MaxSubSum.cpp: #include#include #include using namespace std; vector max_subseq_sum_alg4_collect(const vector &, int&); void print_vector(const vector &); int main() { vector myseq; ifstream inp; inp.open("lab2ex2_input.txt"); // uniform input for all int next; inp >> next; myseq.push_back(next); while (!inp.fail()) { myseq.push_back(next); inp >> next; } cout maxsubseq; int maxsum; maxsubseq = max_subseq_sum_alg4_collect(myseq, maxsum); cout max_subseq_sum_alg4_collect(const vector & vec, int& max) { int maxsum = 0; int localsum = 0; vector maxseq; vector localseq; for (int i = 0; i maxsum) { maxsum = localsum; maxseq = localseq; } else if (localsum & vec) { for (int i = 0; i this has to be the output:
Vectormax_subseq_sum_collect_rand1 (const Vector int>& vec, int& max) { int k = rand_int(0, vec.size() - 1); init = vec[k]; int maxsum = vec[k]; int localsum = 0; Vector maxseq; Vector localseq; for (int i = 0; i maxsum) { maxsum = localsum; maxseq = localseq; } if (localsum
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started