Here are the test results for you and your friend. The first line has the number
ID: 3790451 • Letter: H
Question
Here are the test results for you and your friend. The first line has the number of questions, the second line has the list of questions that you got right. The third line has the list of questions that your friend answered correctly.
25
1-5,7-10,18-23,
12-16,8 2,5-8,15-25
Output the following ones:
A+B: 1-10, 12-25 (union of 2 sets)
A~B: 2,5,7-8,15-16,18-23 (intersection of 2 sets)
A-B: 1,3-4,9-10,12-14 (you got these right, your friend missed) B-A: 6,17 (your friend got these right, you missed)
Code:
#include <iostream>
#include <string>
Since each one of them requires us to output a result, create a new function
void printResult(bool *output)
{
…
}
And use it to output each result.
Explanation / Answer
#include #include using namespace std; int numQuestions; //bool myResults[1000]; static array bool *process(string input) { bool *outputArray = new bool [numQuestions]; for(int i=0 ; i> number1) { separator = ' '; stringInput >> separator; //read a character if (separator == '-') { stringInput >> number2; //read the next number //set true for the range of numbers for(int i=number1 ; i> separator; } else // set the flag true only for one number outputArray[number1] = true; } return outputArray; } void outputUnion(bool *myArray, bool *yourArray) { bool *output = new bool [numQuestions]; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.