Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write in C++ only A1.txt file contains Thank you Program 1 - 25 pts 1. An input

ID: 3687824 • Letter: W

Question

Write in C++ only

A1.txt file contains

Thank you

Program 1 - 25 pts 1. An input file A1.txt is given where each line consists of two integers: n and r. 2. Read each line of the input file using a loop and perform the following operations: (a) If n is a positive integer and r is a nonnegative integer where r n, then print 'r > n error Note: You have to read the file using loops. The number of lines in Al.txt can be more than 10 1 Sample input: 2 7 2 s Sample output: G7 2 42 21 78 9 r>n error

Explanation / Answer

void combinations_r_recursive(

const vector<char> &elems,

unsigned long req_len,

vector<unsigned long> &pos,

unsigned long depth,

unsigned long margin

)

{

// Have we selected the number of required elements?

if (depth >= req_len) {

    for (unsigned long ii = 0; ii < pos.size(); ++ii)

      cout << elems[pos[ii]];

    cout << endl;

    return;

}

// Try to select new elements in the same position or

// to the right of the last selected one.

for (unsigned long ii = margin; ii < elems.size(); ++ii) {

    pos[depth] = ii;

    combinations_r_recursive(elems, req_len, pos, depth + 1, ii);

}

return;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote