SlideShare a Scribd company logo
C++ Language
** Dynamic Memory **
There are 7 files in this project, and they are down below. And I guess the professor wants us to
modify the set.cpp make sure the numbers are entered by the user to be set dynamically. If you
pay attention to the set.cpp I marked in bold a section that may be needed to be changed. I have
put all the codes down so that you can copy them to your computer to have an idea of how they
work together. Only that Set.cpp must be modified so the number of elements can be set
dynamically during the program's execution. And please can you be more specific about what
line of code needs to be replaced?
Here are the professor's instructions.
** Note: The goal of this assignment is to MODIFY the existing code. **
Implement a dynamically allocated version of the mathematical concept of a 'set'. First, examine
the provided library and driver (in main) for a statically allocated Set class. You may also want
to refresh your mathematical memory of the set concept before proceeding.
Now that you are familiar with how the Set class works, let's make it work better. Currently, the
user is limited to a certain maximum number of elements in their Set. Change it so the number of
elements can be set dynamically during the program's execution.
Extend the driver to test all the ADT's operations.
** Things to Consider **
1. If your set is implemented in dynamic memory:
1a. How do you access the members?
1b. How and when do you re-size the memory?
HERE are the CODE files:.
main.cpp
include <iostream>
#include <cctype>
#include "input.h"
#include "set.h"
using namespace std;
int main(void)
{
Set x, y, z;
bool quit;
long newone;
do
{
cout << "Enter a long integer: ";
cin >> newone;
if (x.ismember(newone))
{
cout << "You've already entered that!" << endl;
}
else
{
x.add_elem(newone);
cout << "Value added to list!" << endl;
}
quit = toupper(get_in_set("YyNn", "Would you like to enter more? ")) == 'N';
} while (!quit && !x.full());
cout << "Overall, you entered: " << endl;
x.output(cout);
cout << endl;
cout << "Please enter a set of long integers: ";
x.input(cin);
cout << endl << "You entered:n";
x.output(cout);
cout << endl;
cout << "Please enter another set of long integers: ";
y.input(cin);
cout << endl << "You entered:n";
y.output(cout);
cout << endl;
cout << "The union of the two sets is:n";
z = x;
z.union_with(y);
z.output(cout);
cout << endl;
cout << "The intersection of the two sets is:n";
z = x;
z.intersection(y);
z.output(cout);
cout << endl;
return 0;
}
input.cpp
#include "input.h"
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;
// Boundaries are assumed to be solid -- low <= value <= high.
// Enum to say which end is to be bounded...
//
// enum BoundType { Low, High, Both };
// Bounded entry function for long integers...
//
long get_bounded(long low,
long high,
const char prompt[] /* = "Enter bounded value: " */,
BoundType which_end /* = Both */)
{
long value;
cout << prompt;
cin >> value;
while ((((which_end == Low) || (which_end == Both)) && (low > value)) ||
(((which_end == High) || (which_end == Both)) && (value > high)))
{
cout << "Please enter a value ";
if (which_end == Both) {
cout << "between " << low << " and " << high << " inclusive!";
}
else if (which_end == Low) {
cout << "greater than or equal to " << low << "!";
}
else {
cout << "less than or equal to " << high << "!";
}
cout << endl << prompt;
cin >> value;
}
return value;
}
// Overloaded for double data...
//
double get_bounded(double low,
double high,
const char prompt[] /* = "Enter bounded value: " */,
BoundType which_end /* = Both */)
{
double value;
cout << prompt;
cin >> value;
while ((((which_end == Low) || (which_end == Both)) && (low > value)) ||
(((which_end == High) || (which_end == Both)) && (value > high)))
{
cout << "Please enter a value ";
if (which_end == Both) {
cout << "between " << low << " and " << high << " inclusive!";
}
else if (which_end == Low) {
cout << "greater than or equal to " << low << "!";
}
else {
cout << "less than or equal to " << high << "!";
}
cout << endl << prompt;
cin >> value;
}
return value;
}
// Limiting a character entry to one of a few...
//
char get_in_set(const char set[] /* = "YyNn" */,
const char prompt[] /* = "Shall we play a game? " */,
const char errmsg[] /* = "nInvalid entry..."
"try again, schmuck!nn" */)
{
char response;
cout << prompt;
cin >> response;
while (strchr(set, response) == nullptr)
{
cout << errmsg << prompt;
cin >> response;
}
return response;
}
// look at the next non-whitespace character
//
char peek(istream & in)
{
while (isspace(in.peek()))
{
in.ignore();
}
return (char)in.peek();
}
input.h
set.h
set.cpp
#include "set.h"
#include <iostream>
#include <cctype>
#include "srchsort.h"
#include "input.h"
using namespace std;
long Set::find(const long item) const
{
return bin_search(the_set, 0, cur_elem-1, item);
}
void Set::arrange(void)
{
sort(the_set, 0, cur_elem-1);
return;
}
bool Set::add_elem(const long item)
{
bool worked = false;
if (cur_elem < MAX_SET)
{
worked = true;
the_set[cur_elem++] = item;
if (cur_elem > 1)
{
arrange();
rem_dupl();
}
}
return worked;
}
void Set::rem_elem(const long item, const long from_where)
{
for (long i = from_where; i < (cur_elem-1); i++)
{
the_set[i] = the_set[i+1];
}
cur_elem--;
return;
}
Set::Set(void) : cur_elem(0)
{
}
bool Set::ismember(const long item) const
{
return (find(item) >= 0);
}
bool Set::union_with(const Set & set)
{
for (long i = 0; i < set.cur_elem; i++)
{
add_elem(set.the_set[i]);
}
return true;
}
bool Set::difference(const Set & set)
{
for (long i = 0; i < set.cur_elem; i++)
{
rem_elem(set.the_set[i]);
}
return true;
}
// this is TERRIBLY inefficient!!! MUST fix someday...
bool Set::intersection(const Set & set)
{
Set t(*this); // my twin?
t.difference(set); // remove common parts
difference(t); // now remove rest from me
return true;
}
bool Set::rem_elem(const long item)
{
long at;
if ((at = find(item)) >= 0)
{
rem_elem(item, at);
}
return (at >= 0);
}
void Set::output(ostream & out) const
{
long i;
out << " { ";
for (i = 0; i < cur_elem; i++)
{
out << the_set[i] << " ";
if (((i+1)%7) == 0)
{
out << endl << " ";
}
}
out << "}";
if ((i%7) == 0)
{
out << endl;
}
return;
}
void Set::input(istream & in)
{
char brace;
long i;
in >> brace;
i = 0;
while ((i < MAX_SET) && !in.eof() && isdigit(peek(in)))
{
in >> the_set[i++];
}
in >> brace;
cur_elem = i;
arrange();
rem_dupl();
return;
}
void Set::rem_dupl(void)
{
long i = 0;
while (i < (cur_elem-1))
{
if (the_set[i] == the_set[i+1])
{
rem_elem(the_set[i], i);
}
else
{
i++;
}
}
return;
}
bool Set::full(void) const
{
return (cur_elem == MAX_SET);
}
srchsort.cpp
srchsort.h
C input.h > ... Line 11: Col 18 " archsort.cpp > f bin_search C srchsort.h > ...
Ad

More Related Content

Similar to C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf (20)

C++ Programs
C++ ProgramsC++ Programs
C++ Programs
NarayanlalMenariya
 
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docxLab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
DIPESH30
 
C++ file
C++ fileC++ file
C++ file
Mukund Trivedi
 
C++ file
C++ fileC++ file
C++ file
Mukund Trivedi
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
WaheedAnwar20
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdf
aksachdevahosymills
 
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
bradburgess22840
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptx
ShashiShash2
 
polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.
UdayGumre
 
C++ practical
C++ practicalC++ practical
C++ practical
Rahul juneja
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework Help
C++ Homework Help
 
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdfThis code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
aamousnowov
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
Thesis Scientist Private Limited
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
premrings
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - Reference
Mohammed Sikander
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
mallik3000
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdf
anandatalapatra
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
RehmanRasheed3
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
arjuncollection
 
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docxLab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
Lab01Filesbuild.bat@echo offclsset DRIVE_LETTER=1.docx
DIPESH30
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdf
aksachdevahosymills
 
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
bradburgess22840
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptx
ShashiShash2
 
polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.
UdayGumre
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework Help
C++ Homework Help
 
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdfThis code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
aamousnowov
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
premrings
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - Reference
Mohammed Sikander
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
mallik3000
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdf
anandatalapatra
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
arjuncollection
 

More from aassecuritysystem (20)

You have an F2 generation derived from two true-breeding parents (AA a.pdf
You have an F2 generation derived from two true-breeding parents (AA a.pdfYou have an F2 generation derived from two true-breeding parents (AA a.pdf
You have an F2 generation derived from two true-breeding parents (AA a.pdf
aassecuritysystem
 
You are measuring photosynthesis within forest leaves and generate the.pdf
You are measuring photosynthesis within forest leaves and generate the.pdfYou are measuring photosynthesis within forest leaves and generate the.pdf
You are measuring photosynthesis within forest leaves and generate the.pdf
aassecuritysystem
 
X-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdf
X-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdfX-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdf
X-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdf
aassecuritysystem
 
Which of the following statements about landfill processes is false- G.pdf
Which of the following statements about landfill processes is false- G.pdfWhich of the following statements about landfill processes is false- G.pdf
Which of the following statements about landfill processes is false- G.pdf
aassecuritysystem
 
What will the following Python program print out- Explain the output d.pdf
What will the following Python program print out- Explain the output d.pdfWhat will the following Python program print out- Explain the output d.pdf
What will the following Python program print out- Explain the output d.pdf
aassecuritysystem
 
Which of the following statements regarding Red Bull's promotional str.pdf
Which of the following statements regarding Red Bull's promotional str.pdfWhich of the following statements regarding Red Bull's promotional str.pdf
Which of the following statements regarding Red Bull's promotional str.pdf
aassecuritysystem
 
Which statement about how investment impacts economic growth is true-.pdf
Which statement about how investment impacts economic growth is true-.pdfWhich statement about how investment impacts economic growth is true-.pdf
Which statement about how investment impacts economic growth is true-.pdf
aassecuritysystem
 
What is the purpose of a vision statement- Select the correct option a.pdf
What is the purpose of a vision statement- Select the correct option a.pdfWhat is the purpose of a vision statement- Select the correct option a.pdf
What is the purpose of a vision statement- Select the correct option a.pdf
aassecuritysystem
 
Using year 0 (now) as the base year- the expenses for two economic alt.pdf
Using year 0 (now) as the base year- the expenses for two economic alt.pdfUsing year 0 (now) as the base year- the expenses for two economic alt.pdf
Using year 0 (now) as the base year- the expenses for two economic alt.pdf
aassecuritysystem
 
Using Processing 4 (Java)- create a sketch that allows you to draw an.pdf
Using Processing 4 (Java)- create a sketch that allows you to draw an.pdfUsing Processing 4 (Java)- create a sketch that allows you to draw an.pdf
Using Processing 4 (Java)- create a sketch that allows you to draw an.pdf
aassecuritysystem
 
Thirty years ago- Clarkin was a small city (about 70-000 residents) th.pdf
Thirty years ago- Clarkin was a small city (about 70-000 residents) th.pdfThirty years ago- Clarkin was a small city (about 70-000 residents) th.pdf
Thirty years ago- Clarkin was a small city (about 70-000 residents) th.pdf
aassecuritysystem
 
The Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdf
The Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdfThe Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdf
The Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdf
aassecuritysystem
 
The following is the balance sheet numbers reported by Bay Bank for 20.pdf
The following is the balance sheet numbers reported by Bay Bank for 20.pdfThe following is the balance sheet numbers reported by Bay Bank for 20.pdf
The following is the balance sheet numbers reported by Bay Bank for 20.pdf
aassecuritysystem
 
The economy is in long run equilibrium- there is a positive AD shock i.pdf
The economy is in long run equilibrium- there is a positive AD shock i.pdfThe economy is in long run equilibrium- there is a positive AD shock i.pdf
The economy is in long run equilibrium- there is a positive AD shock i.pdf
aassecuritysystem
 
Summary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdf
Summary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdfSummary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdf
Summary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdf
aassecuritysystem
 
Special Senses 1- What are the three layers or the neural tunic of the.pdf
Special Senses 1- What are the three layers or the neural tunic of the.pdfSpecial Senses 1- What are the three layers or the neural tunic of the.pdf
Special Senses 1- What are the three layers or the neural tunic of the.pdf
aassecuritysystem
 
Significant differences between experimentally observed allele frequen.pdf
Significant differences between experimentally observed allele frequen.pdfSignificant differences between experimentally observed allele frequen.pdf
Significant differences between experimentally observed allele frequen.pdf
aassecuritysystem
 
Say the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdf
Say the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdfSay the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdf
Say the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdf
aassecuritysystem
 
Disk drives have been getting larger- Their capacity is now often give.pdf
Disk drives have been getting larger- Their capacity is now often give.pdfDisk drives have been getting larger- Their capacity is now often give.pdf
Disk drives have been getting larger- Their capacity is now often give.pdf
aassecuritysystem
 
Diaz Company reports the following variable costing income statement f.pdf
Diaz Company reports the following variable costing income statement f.pdfDiaz Company reports the following variable costing income statement f.pdf
Diaz Company reports the following variable costing income statement f.pdf
aassecuritysystem
 
You have an F2 generation derived from two true-breeding parents (AA a.pdf
You have an F2 generation derived from two true-breeding parents (AA a.pdfYou have an F2 generation derived from two true-breeding parents (AA a.pdf
You have an F2 generation derived from two true-breeding parents (AA a.pdf
aassecuritysystem
 
You are measuring photosynthesis within forest leaves and generate the.pdf
You are measuring photosynthesis within forest leaves and generate the.pdfYou are measuring photosynthesis within forest leaves and generate the.pdf
You are measuring photosynthesis within forest leaves and generate the.pdf
aassecuritysystem
 
X-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdf
X-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdfX-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdf
X-Y and Z are i-i-d- random variables uniform in (0-1)- Find E{X+Y+ZX}.pdf
aassecuritysystem
 
Which of the following statements about landfill processes is false- G.pdf
Which of the following statements about landfill processes is false- G.pdfWhich of the following statements about landfill processes is false- G.pdf
Which of the following statements about landfill processes is false- G.pdf
aassecuritysystem
 
What will the following Python program print out- Explain the output d.pdf
What will the following Python program print out- Explain the output d.pdfWhat will the following Python program print out- Explain the output d.pdf
What will the following Python program print out- Explain the output d.pdf
aassecuritysystem
 
Which of the following statements regarding Red Bull's promotional str.pdf
Which of the following statements regarding Red Bull's promotional str.pdfWhich of the following statements regarding Red Bull's promotional str.pdf
Which of the following statements regarding Red Bull's promotional str.pdf
aassecuritysystem
 
Which statement about how investment impacts economic growth is true-.pdf
Which statement about how investment impacts economic growth is true-.pdfWhich statement about how investment impacts economic growth is true-.pdf
Which statement about how investment impacts economic growth is true-.pdf
aassecuritysystem
 
What is the purpose of a vision statement- Select the correct option a.pdf
What is the purpose of a vision statement- Select the correct option a.pdfWhat is the purpose of a vision statement- Select the correct option a.pdf
What is the purpose of a vision statement- Select the correct option a.pdf
aassecuritysystem
 
Using year 0 (now) as the base year- the expenses for two economic alt.pdf
Using year 0 (now) as the base year- the expenses for two economic alt.pdfUsing year 0 (now) as the base year- the expenses for two economic alt.pdf
Using year 0 (now) as the base year- the expenses for two economic alt.pdf
aassecuritysystem
 
Using Processing 4 (Java)- create a sketch that allows you to draw an.pdf
Using Processing 4 (Java)- create a sketch that allows you to draw an.pdfUsing Processing 4 (Java)- create a sketch that allows you to draw an.pdf
Using Processing 4 (Java)- create a sketch that allows you to draw an.pdf
aassecuritysystem
 
Thirty years ago- Clarkin was a small city (about 70-000 residents) th.pdf
Thirty years ago- Clarkin was a small city (about 70-000 residents) th.pdfThirty years ago- Clarkin was a small city (about 70-000 residents) th.pdf
Thirty years ago- Clarkin was a small city (about 70-000 residents) th.pdf
aassecuritysystem
 
The Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdf
The Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdfThe Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdf
The Feedfish App putlic Maisindilaryit- O-9eerile ievpeindy i-public c.pdf
aassecuritysystem
 
The following is the balance sheet numbers reported by Bay Bank for 20.pdf
The following is the balance sheet numbers reported by Bay Bank for 20.pdfThe following is the balance sheet numbers reported by Bay Bank for 20.pdf
The following is the balance sheet numbers reported by Bay Bank for 20.pdf
aassecuritysystem
 
The economy is in long run equilibrium- there is a positive AD shock i.pdf
The economy is in long run equilibrium- there is a positive AD shock i.pdfThe economy is in long run equilibrium- there is a positive AD shock i.pdf
The economy is in long run equilibrium- there is a positive AD shock i.pdf
aassecuritysystem
 
Summary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdf
Summary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdfSummary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdf
Summary SHORT PAPER- Review the case on p- 87 Chapters 4- Prepare a sh.pdf
aassecuritysystem
 
Special Senses 1- What are the three layers or the neural tunic of the.pdf
Special Senses 1- What are the three layers or the neural tunic of the.pdfSpecial Senses 1- What are the three layers or the neural tunic of the.pdf
Special Senses 1- What are the three layers or the neural tunic of the.pdf
aassecuritysystem
 
Significant differences between experimentally observed allele frequen.pdf
Significant differences between experimentally observed allele frequen.pdfSignificant differences between experimentally observed allele frequen.pdf
Significant differences between experimentally observed allele frequen.pdf
aassecuritysystem
 
Say the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdf
Say the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdfSay the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdf
Say the Dow Jones Industrial Average was 300 in October 1929 and 100 i.pdf
aassecuritysystem
 
Disk drives have been getting larger- Their capacity is now often give.pdf
Disk drives have been getting larger- Their capacity is now often give.pdfDisk drives have been getting larger- Their capacity is now often give.pdf
Disk drives have been getting larger- Their capacity is now often give.pdf
aassecuritysystem
 
Diaz Company reports the following variable costing income statement f.pdf
Diaz Company reports the following variable costing income statement f.pdfDiaz Company reports the following variable costing income statement f.pdf
Diaz Company reports the following variable costing income statement f.pdf
aassecuritysystem
 
Ad

Recently uploaded (20)

Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdfIPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
Quiz Club of PSG College of Arts & Science
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdfGENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
Quiz Club of PSG College of Arts & Science
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Module_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptxModule_2_Types_and_Approaches_of_Research (2).pptx
Module_2_Types_and_Approaches_of_Research (2).pptx
drroxannekemp
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Ad

C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf

  • 1. C++ Language ** Dynamic Memory ** There are 7 files in this project, and they are down below. And I guess the professor wants us to modify the set.cpp make sure the numbers are entered by the user to be set dynamically. If you pay attention to the set.cpp I marked in bold a section that may be needed to be changed. I have put all the codes down so that you can copy them to your computer to have an idea of how they work together. Only that Set.cpp must be modified so the number of elements can be set dynamically during the program's execution. And please can you be more specific about what line of code needs to be replaced? Here are the professor's instructions. ** Note: The goal of this assignment is to MODIFY the existing code. ** Implement a dynamically allocated version of the mathematical concept of a 'set'. First, examine the provided library and driver (in main) for a statically allocated Set class. You may also want to refresh your mathematical memory of the set concept before proceeding. Now that you are familiar with how the Set class works, let's make it work better. Currently, the user is limited to a certain maximum number of elements in their Set. Change it so the number of elements can be set dynamically during the program's execution. Extend the driver to test all the ADT's operations. ** Things to Consider ** 1. If your set is implemented in dynamic memory: 1a. How do you access the members? 1b. How and when do you re-size the memory? HERE are the CODE files:. main.cpp include <iostream> #include <cctype> #include "input.h" #include "set.h" using namespace std;
  • 2. int main(void) { Set x, y, z; bool quit; long newone; do { cout << "Enter a long integer: "; cin >> newone; if (x.ismember(newone)) { cout << "You've already entered that!" << endl; } else { x.add_elem(newone); cout << "Value added to list!" << endl; } quit = toupper(get_in_set("YyNn", "Would you like to enter more? ")) == 'N'; } while (!quit && !x.full()); cout << "Overall, you entered: " << endl; x.output(cout); cout << endl; cout << "Please enter a set of long integers: "; x.input(cin); cout << endl << "You entered:n"; x.output(cout); cout << endl; cout << "Please enter another set of long integers: "; y.input(cin); cout << endl << "You entered:n"; y.output(cout); cout << endl; cout << "The union of the two sets is:n"; z = x; z.union_with(y); z.output(cout); cout << endl; cout << "The intersection of the two sets is:n"; z = x;
  • 3. z.intersection(y); z.output(cout); cout << endl; return 0; } input.cpp #include "input.h" #include <iostream> #include <cstring> #include <cctype> using namespace std; // Boundaries are assumed to be solid -- low <= value <= high. // Enum to say which end is to be bounded... // // enum BoundType { Low, High, Both }; // Bounded entry function for long integers... // long get_bounded(long low, long high, const char prompt[] /* = "Enter bounded value: " */, BoundType which_end /* = Both */) { long value; cout << prompt; cin >> value; while ((((which_end == Low) || (which_end == Both)) && (low > value)) || (((which_end == High) || (which_end == Both)) && (value > high))) { cout << "Please enter a value "; if (which_end == Both) { cout << "between " << low << " and " << high << " inclusive!"; } else if (which_end == Low) { cout << "greater than or equal to " << low << "!"; } else { cout << "less than or equal to " << high << "!"; } cout << endl << prompt;
  • 4. cin >> value; } return value; } // Overloaded for double data... // double get_bounded(double low, double high, const char prompt[] /* = "Enter bounded value: " */, BoundType which_end /* = Both */) { double value; cout << prompt; cin >> value; while ((((which_end == Low) || (which_end == Both)) && (low > value)) || (((which_end == High) || (which_end == Both)) && (value > high))) { cout << "Please enter a value "; if (which_end == Both) { cout << "between " << low << " and " << high << " inclusive!"; } else if (which_end == Low) { cout << "greater than or equal to " << low << "!"; } else { cout << "less than or equal to " << high << "!"; } cout << endl << prompt; cin >> value; } return value; } // Limiting a character entry to one of a few... // char get_in_set(const char set[] /* = "YyNn" */, const char prompt[] /* = "Shall we play a game? " */, const char errmsg[] /* = "nInvalid entry..." "try again, schmuck!nn" */) { char response; cout << prompt; cin >> response; while (strchr(set, response) == nullptr) {
  • 5. cout << errmsg << prompt; cin >> response; } return response; } // look at the next non-whitespace character // char peek(istream & in) { while (isspace(in.peek())) { in.ignore(); } return (char)in.peek(); } input.h set.h set.cpp #include "set.h" #include <iostream> #include <cctype> #include "srchsort.h" #include "input.h" using namespace std; long Set::find(const long item) const { return bin_search(the_set, 0, cur_elem-1, item); } void Set::arrange(void) { sort(the_set, 0, cur_elem-1); return; } bool Set::add_elem(const long item)
  • 6. { bool worked = false; if (cur_elem < MAX_SET) { worked = true; the_set[cur_elem++] = item; if (cur_elem > 1) { arrange(); rem_dupl(); } } return worked; } void Set::rem_elem(const long item, const long from_where) { for (long i = from_where; i < (cur_elem-1); i++) { the_set[i] = the_set[i+1]; } cur_elem--; return; } Set::Set(void) : cur_elem(0) { } bool Set::ismember(const long item) const { return (find(item) >= 0); } bool Set::union_with(const Set & set) { for (long i = 0; i < set.cur_elem; i++) { add_elem(set.the_set[i]); } return true; }
  • 7. bool Set::difference(const Set & set) { for (long i = 0; i < set.cur_elem; i++) { rem_elem(set.the_set[i]); } return true; } // this is TERRIBLY inefficient!!! MUST fix someday... bool Set::intersection(const Set & set) { Set t(*this); // my twin? t.difference(set); // remove common parts difference(t); // now remove rest from me return true; } bool Set::rem_elem(const long item) { long at; if ((at = find(item)) >= 0) { rem_elem(item, at); } return (at >= 0); } void Set::output(ostream & out) const { long i; out << " { "; for (i = 0; i < cur_elem; i++) { out << the_set[i] << " "; if (((i+1)%7) == 0) { out << endl << " "; } } out << "}"; if ((i%7) == 0) { out << endl; }
  • 8. return; } void Set::input(istream & in) { char brace; long i; in >> brace; i = 0; while ((i < MAX_SET) && !in.eof() && isdigit(peek(in))) { in >> the_set[i++]; } in >> brace; cur_elem = i; arrange(); rem_dupl(); return; } void Set::rem_dupl(void) { long i = 0; while (i < (cur_elem-1)) { if (the_set[i] == the_set[i+1]) { rem_elem(the_set[i], i); } else { i++; } } return; } bool Set::full(void) const { return (cur_elem == MAX_SET); } srchsort.cpp srchsort.h
  • 9. C input.h > ... Line 11: Col 18 " archsort.cpp > f bin_search C srchsort.h > ...
  翻译: