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

I have a quick question for C++ I need to write a code in the lanuage C++ for a

ID: 3718095 • Letter: I

Question

I have a quick question for C++

I need to write a code in the lanuage C++ for a project that I am working on.

***I need to create three sets of 100 integers randomally generated between 0 and 1000 and display the sets

***The numbers must seed randomally with an RNG srand(time(NULL))

***I must display all the the integers that appear in AT LEAST 2 of the 3 sets

***If possible, I only display the integer(s) once if it appears in at least 2 of the 3 sets. In other words, if the interger 5 appears six in times in all three sets, the code only returns the integer 5 once and not six times.

Thank you, and have a wonderful day!!

Explanation / Answer

lets maintain an array of structures.

struct node {
bool flag;
char availability;
} node;

node arr[1000];

whole idea behind it, as number can be on the range 1 t thousand, so have taken array of size 1000. And directly access array node.

here flag will tell whenever node enabled. and avilability have the number significant:

lets three bits of availability node: so when first bit on - 1 then numbe ravailable on set 1.
when . 10 ->means 2 ->number available for set 2/.
when 100 -> means 4 > number availabe for set 3.

and simiarly with combination it can of ->>>>> . 101 . -> number is available in first and third set. and when 111 -> number present in all three sets. by this trick searchinh would be easy.

now lets write the function to return availability of function.

void func_present(node arr[1000])
{
for (int loop = 0;loop < 1000;loop++)
{
char avail = arr[loop].availability;
if (avail == 3 || avail == 5 || avail == 7)
{
printf("%d", (loop+1))
}

}

}

Thanks.