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
The process of making raw materials into a finished product is known as
Olin [163]
1.) Business Engineering or Manufacturing :)
<span />
6 0
3 years ago
Read 2 more answers
Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string
Svetach [21]

Answer:

def length( mystring):

   count = 0

   for i in mystring:

       count += 1

   return count

def reversed( mystring):

   strlist = []

   for i in range(length(mystring)):

       strlist.append(mystring[(length(mystring) - 1) - i])

       txt = "".join(strlist)

   return txt

string = 'Yolanda'

print(reversed(string))

Explanation:

The python module defines two functions 'reversed' and 'length'. The length function counts the number of characters in a string variable while the reversed function reverses the string variable value.

3 0
2 years ago
When saving a memo you created in Word, which one of the following extensions is automatically assigned to the document?
VMariaS [17]
What are the options and if it's meaning like when you save something it has .pdf .jpg or .doc after the title then it would be ".doc"
8 0
3 years ago
What is MARC? Discuss structure of MARC
nordsb [41]
What do you mean? I don't understand.
7 0
3 years ago
What is the purpose behind the Three Phase Commit? It improves upon the two phased commit by requiring that locks be acquired at
Ray Of Light [21]
The answer is a) It improves upon the two-phased commit by requiring that locks be acquired at the start of a transaction.

Reason: The 3PC is an extension or you can say developed from 2PC that avoids blocking of an operation. It just ensures that first n sites have intended to commit a transaction that means it acquires commits or locks before the start of any transaction to avoid any blocking.

Option b) is wrong as it does not allow coordination, it just let all the other sites do their transaction if any other site is blocked, so no coordination is there between sites that they will wait till their coordinator is corrected.

Option c) is wrong as lock operations are shared between other connections as when their coordinator fails, the new coordinator agrees to the old coordinator that they had shared locks before and they can start their transaction.

Option d) is wrong as option a) is correct.

If you like the answer, please upvote.
4 0
2 years ago
Other questions:
  • Define the method object inc_num_kids() for personinfo. inc_num_kids increments the member data num_kids. sample output for the
    11·1 answer
  • Why is it important to explore an Integrated
    13·1 answer
  • ----------HELP WITH 3 QUESTIONS FOR 30 POINTS!!!---------
    6·1 answer
  • A one-to-many binary relationship allows an occurrence of the entity type on the "one side" of the relationship to be associated
    5·1 answer
  • Which of the following scenarios can best be addressed by operations management?
    11·1 answer
  • A firm can survive and succeed in the long run if it successfully develops strategies to confront the _______________ that shape
    9·1 answer
  • PLEASE HELP ASAP!!! 99 POINTS FOR 3 MULTIPLE CHOICE QUESTIONS!!! PLEASE ANSWER ALL!!!
    8·1 answer
  • Why do I keep getting points if I haven't answered anything? I don't want points.
    12·1 answer
  • Suppression of politically or socially unacceptable co
    5·1 answer
  • Online activities among businesses
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!