**Q:**

the input to the following C function is an array of n sorted positive

integers A[1..n], where S is the summation of all its terms (from 1 to n).

void choose(int A[], int n, int K)

{

for (k = 0; k < K; k++)

{

r = rand() % S + 1;

sum = 0;

for (i = 0; (i <= n) && (sum < r); i++)

sum += A[i];

print i;

}

}

**A:**

I do not know what this program does.

This is something like a puzzle that I do not solve. If you wrote this

code, you certainly should know what it does.

Regards,

Peter

[ back to toc ]