1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gizmo_the_mogwai [7]
3 years ago
12

Have main create two objects: setA and setB.Input the values into setA (end with a 0 or negative) and input the values into setB

(end with 0 or negative).Print the ordered pairs using printOrderedPairs.Print if setA is a subset of setB.Then print if setA is a proper subset of setB.
Computers and Technology
1 answer:
kvasek [131]3 years ago
6 0

Answer:

C code is explained below

Explanation:

Sets.h:

#ifndef SETS_H

#define SETS_H

class Sets

{

    private:

         static const int s = 4;

         int na[s];

    public:

         //for constructor

         Sets();

         //function declaration for add the element

         void addElement(int);

         //function declaration for get the element

         int getElement(int);

         //function declaration for get size

         int getSize();

         //function declaration for check sub set

         bool isSubset(const Sets &);

         //function declaration for check the proper subset

         bool isProper(const Sets &);

         //function declaration for display the set

         void printSet();

         //function declaration for display the ordered set

         void Sets::printOrderedPairs( const Sets &);

};

#endif

Main.cpp:

#include "Sets.h"

#include <iostream>

using namespace std;

//constructor

Sets::Sets(){

   for (int i = 0; i < s; i++){

       na[i] = -1;

   }

}

//function definition for get size

int Sets::getSize(){

   return s;

}

//function definition for add the elements

void Sets::addElement(int l){

   for (int i = 0; i < s; i++){

       if (na[i] == -1){

           na[i] = l;

           break;

       }

   }

}

//function definition for get element

int Sets::getElement(int j){

   if (j < s){

       return (-1);

   }

   else{

       int t;

       t = na[j];

       return t;

   }

}

//function definition for check the subset

bool Sets::isSubset( const Sets &b ) {

  for (int i = 0, j = 0; i < b.s; i++ ) {

          while ( j < s && na[j] < b.na[i] ) ++j;

       if ( j == s || na[j] > b.na[i] )

           return false;

   }

   return true;

}

//function definition for check the proper subset

bool Sets::isProper( const Sets &b ) {

   int ne = 0;

   for (int i = 0, j = 0; i < b.s; i++ ) {

       while ( j < s && na[j] < b.na[i] ) ++j;

       if ( j == s || na[j] > b.na[i] )

           return false;

       ++ne;

   }

   return ne < s;

}

//function definition for display the ordered set

void Sets::printOrderedPairs( const Sets &b){

   cout << "A X B = {";

   for (int i = 0; i < s; i++){

       for (int j = 0; j < b.s; j++){

           cout << '(' << na[i] << ", " << b.na[j] << "), ";

     }

   }

   cout << "\b\b} ";

}

//function definition for display the set

void Sets::printSet(){

   cout << "{";

   for (int i = 0; i < s; i++){

       cout << na[i] << ",";

   }

   cout << "}";

}

//main function

int main()

{

   //object for Set A

   Sets a;

   //object for Set B

   Sets b;

   //add the element for Set A

   a.addElement(1);

   a.addElement(2);

   a.addElement(3);

   a.addElement(4);

    //add the element for Set B

   b.addElement(3);

   b.addElement(4);

   b.addElement(5);

   b.addElement(6);

   //display the set A

   cout << "Set A: ";

   a.printSet();

   cout << endl;

   //display the set B

   cout << "Set B: ";

   b.printSet();

   cout << "\n" << endl;

   //display the A X B

    a.printOrderedPairs(b);

   cout << "\n" << endl;

    //chrck the subset

   if (a.isSubset(b) == true){

       cout << "Set B is subset of set A" << endl;

   }

   else{

       cout << "Set B is not a subset of set A" << endl;

   }

    //check the proper subset

   if (a.isProper(b) == true){

       cout << "Set B is proper subset of set A" << endl;

   }

   else{

        cout << "Set B is not a proper subset of set A" << endl;

   }

   system("PAUSE");

   return 0;

}

You might be interested in
Saas provides services to an organization that requires the standard business process infrastructure such a CRM
Rzqust [24]

Answer: True

Explanation:

 Yes, the given statement is true that the SaaS (Software as a service) provide the different types of services to the organization which basically require the infrastructure like CRM (Customer relationship management) and it is the standard business processing in the organization.

The software as a service is the fundamental technology of the business which basically include the CRM, e-mails and the various types of sale and financial management.

5 0
3 years ago
Which TranscribeMe tag should you use if you are unable to make out a word or phrase due to a difficult accent, poor audio, or a
Lady bird [3.3K]

Answer:

[inaudible]

Explanation:

TranscribeMe is an online transcription company. It employs people all over the world to render transcription services to clients. They have a style guideline which must be strictly adhered to by the transcribers. The guidelines specifically states the "do's " and "dont's" during transcription. Now, when transcribing a word or phrase that cannot be heard or understood due to poor audio or difficult answer, the transcriber uses the tag [inaudible].

5 0
3 years ago
Imagine that you are a professional white hat hacker, testing a company’s system to make sure they are ready for attacks. What m
liberstina [14]

Answer:

A white hat hacker, or ethical hacker, uses penetration testing techniques to test an organization's information technology

Explanation:

3 0
2 years ago
Which is an example of a Boolean operator that evaluates as TRUE?
ladessa [460]

The expression NOT (3+2=7) evaluates as TRUE because is is NOT the case that 3+2=7.

Let me know if you have any questions.

4 0
3 years ago
Which of the following is true about sorting functions?
il63 [147K]

Answer: Option D -- Sorting an already sorted array of size n with quicksort takes O(n log n) time.

Explanation:

Sorting an already sorted array of size n with quicksort takes O(n log n) time is true about sorting functions while other options are wrong.

8 0
3 years ago
Other questions:
  • The North American Free Trade Agreement (NAFTA) among Canada, Mexico, and the United States is intended to _____.
    5·2 answers
  • ____ is another term for document properties.
    12·1 answer
  • In this activity, you'll decide how a computer (in this case, a smartphone)
    12·1 answer
  • A class is a _____, which encapsulates _____ and _____. (Points : 2) programming language construct; attributes; behavior
    7·1 answer
  • How can parents be health educators in family​
    13·1 answer
  • Write a function named change() that has an integer parameter and six integers reference parameters named hundreds, fifties, twe
    7·1 answer
  • Computer privacy typically occurs when which of the following is violated?
    6·1 answer
  • The foundation of secure communication on the internet replies on asymmetric encryption, with the use of Public and Private keys
    10·1 answer
  • Im drinking coffee. and working on school and watching a show. Whos with me?
    9·1 answer
  • Tools used to type text on Ms paint​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!