SlideShare a Scribd company logo
1 of 3
Download to read offline
3. Implement the UnsortedList class to store a list of numbers that are input into the list from
data.txt.
- create a main.cpp file that gets the numbers from the file
- insert the number 7 into the list
- insert another number 300 into the list
- delete the number 6 from the list
- print out the following:
--the entire list
- the greatest
- the least
2. There should be four files, the main.cpp, UnsortedList.cpp, ItemType.h, and the output file
two called outfile2.txt
- Yes you need to make your program output an "outfile2.txt"
Contents of “data.txt
10 8 250 800 -1 6
Solution
main.cpp:
#include
#include
#include
#include
int main ()
{
std::list mylist;
std::list::iterator it;
std::fstream myfile("data.txt");
std::ofstream myfile1("output2.txt");
int a;
while (myfile >> a)
{
mylist.push_back(a);
}
it = mylist.begin();
std::cout << ' ';
std :: cout << "Initial List:";
for (it=mylist.begin(); it!=mylist.end(); ++it)
std::cout << ' ' << *it;
std::cout << ' ';
std::cout << ' ';
std :: cout << "Insert 7:";
mylist.insert (it,7);
for (it=mylist.begin(); it!=mylist.end(); ++it)
std::cout << ' ' << *it;
std::cout << ' ';
std::cout << ' ';
std :: cout << "Intest 300:";
mylist.insert (it,300);
for (it=mylist.begin(); it!=mylist.end(); ++it)
std::cout << ' ' << *it;
std::cout << ' ';
std::cout << ' ';
std :: cout << "Delete 6:";
mylist.remove(6);
for (it=mylist.begin(); it!=mylist.end(); ++it)
std::cout << ' ' << *it;
std::cout << ' ';
std::cout << ' ';
std::cout << "Final list:";
for (it=mylist.begin(); it!=mylist.end(); ++it)
std::cout << ' ' << *it;
myfile1 << *it << std::endl;
std::cout << ' ';
std::cout << ' ';
return 0;
}
UnsortedList.cpp:
#include
#include
#include
#include
int main ()
{
std::list mylist;
std::list::iterator it;
std::fstream myfile("output2.txt");
int a;
int largest;
while (myfile >> a)
{
mylist.push_back(a);
}
it = mylist.begin();
for (it=mylist.begin(); it!=mylist.end(); ++it)
if (*it>largest){
largest=*it;
}
std::cout <<"Largest is:";
std::cout <

More Related Content

Similar to 3. Implement the UnsortedList class to store a list of numbers that .pdf

2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
arshin9
 
Describe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdfDescribe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdf
arihantstoneart
 
You must implement the following functions- Name the functions exactly.docx
You must implement the following functions- Name the functions exactly.docxYou must implement the following functions- Name the functions exactly.docx
You must implement the following functions- Name the functions exactly.docx
Sebastian6SWSlaterb
 
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxLab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
rennaknapp
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
SANDEEPARIHANT
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
RAJATCHUGH12
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
DIPESH30
 
File Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.pdfFile Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.pdf
footworld1
 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
Yashpatel821746
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
rajkumarm401
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
tienlivick
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdf
info334223
 

Similar to 3. Implement the UnsortedList class to store a list of numbers that .pdf (20)

2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf2.(Sorted list array implementation)This sorted list ADT discussed .pdf
2.(Sorted list array implementation)This sorted list ADT discussed .pdf
 
Describe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdfDescribe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdf
 
You must implement the following functions- Name the functions exactly.docx
You must implement the following functions- Name the functions exactly.docxYou must implement the following functions- Name the functions exactly.docx
You must implement the following functions- Name the functions exactly.docx
 
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxLab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
Automate the boring stuff with python
Automate the boring stuff with pythonAutomate the boring stuff with python
Automate the boring stuff with python
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
 
File Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.pdfFile Type cppAdd the following to your linked list of strings pro.pdf
File Type cppAdd the following to your linked list of strings pro.pdf
 
source code which create file and write into it
source code which create file and write into itsource code which create file and write into it
source code which create file and write into it
 
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdfUsing Array Approach, Linked List approach, and Delete Byte Approach.pdf
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
 
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
 
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
 
(C++ exercise) 4. Write a recursive version of the binary search alg.docx
(C++ exercise) 4. Write a recursive version of the binary search alg.docx(C++ exercise) 4. Write a recursive version of the binary search alg.docx
(C++ exercise) 4. Write a recursive version of the binary search alg.docx
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdf
 

More from kisgstin23

Describe the E-C and the players involved in the electrical and mech.pdf
Describe the E-C and the players involved in the electrical and mech.pdfDescribe the E-C and the players involved in the electrical and mech.pdf
Describe the E-C and the players involved in the electrical and mech.pdf
kisgstin23
 
Harden, Harden, & Harden is a venerable Wall Street stock brokerage .pdf
Harden, Harden, & Harden is a venerable Wall Street stock brokerage .pdfHarden, Harden, & Harden is a venerable Wall Street stock brokerage .pdf
Harden, Harden, & Harden is a venerable Wall Street stock brokerage .pdf
kisgstin23
 
Every time we have to make a choice we are faced with an opportunity.pdf
Every time we have to make a choice we are faced with an opportunity.pdfEvery time we have to make a choice we are faced with an opportunity.pdf
Every time we have to make a choice we are faced with an opportunity.pdf
kisgstin23
 
Canadian copyrights on music expire 50 years after the death of t.pdf
Canadian copyrights on music expire 50 years after the death of t.pdfCanadian copyrights on music expire 50 years after the death of t.pdf
Canadian copyrights on music expire 50 years after the death of t.pdf
kisgstin23
 
A linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdfA linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdf
kisgstin23
 
What professions were represented on the teamWhat role did each m.pdf
What professions were represented on the teamWhat role did each m.pdfWhat professions were represented on the teamWhat role did each m.pdf
What professions were represented on the teamWhat role did each m.pdf
kisgstin23
 

More from kisgstin23 (20)

John Smith wrote fraudulent checks and made false statements when ap.pdf
John Smith wrote fraudulent checks and made false statements when ap.pdfJohn Smith wrote fraudulent checks and made false statements when ap.pdf
John Smith wrote fraudulent checks and made false statements when ap.pdf
 
Describe the E-C and the players involved in the electrical and mech.pdf
Describe the E-C and the players involved in the electrical and mech.pdfDescribe the E-C and the players involved in the electrical and mech.pdf
Describe the E-C and the players involved in the electrical and mech.pdf
 
In a large population, 59 of the people have been vaccinated. If 4 .pdf
In a large population, 59  of the people have been vaccinated. If 4 .pdfIn a large population, 59  of the people have been vaccinated. If 4 .pdf
In a large population, 59 of the people have been vaccinated. If 4 .pdf
 
Harden, Harden, & Harden is a venerable Wall Street stock brokerage .pdf
Harden, Harden, & Harden is a venerable Wall Street stock brokerage .pdfHarden, Harden, & Harden is a venerable Wall Street stock brokerage .pdf
Harden, Harden, & Harden is a venerable Wall Street stock brokerage .pdf
 
Every time we have to make a choice we are faced with an opportunity.pdf
Every time we have to make a choice we are faced with an opportunity.pdfEvery time we have to make a choice we are faced with an opportunity.pdf
Every time we have to make a choice we are faced with an opportunity.pdf
 
Complete a Punnett square to show the genotypes and phenotypes expec.pdf
Complete a Punnett square to show the genotypes and phenotypes expec.pdfComplete a Punnett square to show the genotypes and phenotypes expec.pdf
Complete a Punnett square to show the genotypes and phenotypes expec.pdf
 
Did both the North and South initially go to war in 1861 over the is.pdf
Did both the North and South initially go to war in 1861 over the is.pdfDid both the North and South initially go to war in 1861 over the is.pdf
Did both the North and South initially go to war in 1861 over the is.pdf
 
Can really use some help with the following UNIXLINUX commands and .pdf
Can really use some help with the following UNIXLINUX commands and .pdfCan really use some help with the following UNIXLINUX commands and .pdf
Can really use some help with the following UNIXLINUX commands and .pdf
 
Canadian copyrights on music expire 50 years after the death of t.pdf
Canadian copyrights on music expire 50 years after the death of t.pdfCanadian copyrights on music expire 50 years after the death of t.pdf
Canadian copyrights on music expire 50 years after the death of t.pdf
 
Below are common errors. State what was done incorrectly and correct.pdf
Below are common errors. State what was done incorrectly and correct.pdfBelow are common errors. State what was done incorrectly and correct.pdf
Below are common errors. State what was done incorrectly and correct.pdf
 
A linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdfA linked stack is implemented using a standard Node class as follows.pdf
A linked stack is implemented using a standard Node class as follows.pdf
 
A. Karl Marx B. Max Weber C. Erik Olin Wright D. Kingsley Davi.pdf
A. Karl Marx  B. Max Weber  C. Erik Olin Wright  D. Kingsley Davi.pdfA. Karl Marx  B. Max Weber  C. Erik Olin Wright  D. Kingsley Davi.pdf
A. Karl Marx B. Max Weber C. Erik Olin Wright D. Kingsley Davi.pdf
 
4 (Opportunity Cost) You can either spend Spring Break working at hom.pdf
4 (Opportunity Cost) You can either spend Spring Break working at hom.pdf4 (Opportunity Cost) You can either spend Spring Break working at hom.pdf
4 (Opportunity Cost) You can either spend Spring Break working at hom.pdf
 
You isolated an enveloped virus whose virions are able to hemadsorb .pdf
You isolated an enveloped virus whose virions are able to hemadsorb .pdfYou isolated an enveloped virus whose virions are able to hemadsorb .pdf
You isolated an enveloped virus whose virions are able to hemadsorb .pdf
 
What professions were represented on the teamWhat role did each m.pdf
What professions were represented on the teamWhat role did each m.pdfWhat professions were represented on the teamWhat role did each m.pdf
What professions were represented on the teamWhat role did each m.pdf
 
what is the threat and solution for when alice sends a password and .pdf
what is the threat and solution for when alice sends a password and .pdfwhat is the threat and solution for when alice sends a password and .pdf
what is the threat and solution for when alice sends a password and .pdf
 
What is the mechanism of action of Staphylococcus alpha toxinSol.pdf
What is the mechanism of action of Staphylococcus alpha toxinSol.pdfWhat is the mechanism of action of Staphylococcus alpha toxinSol.pdf
What is the mechanism of action of Staphylococcus alpha toxinSol.pdf
 
What is a charismatic leader What problems are charismatic leaders .pdf
What is a charismatic leader What problems are charismatic leaders .pdfWhat is a charismatic leader What problems are charismatic leaders .pdf
What is a charismatic leader What problems are charismatic leaders .pdf
 
What is the difference between sequential file access and random fil.pdf
What is the difference between sequential file access and random fil.pdfWhat is the difference between sequential file access and random fil.pdf
What is the difference between sequential file access and random fil.pdf
 
This theorem was conjectured by Legendre, Gauss, Dirichlet, Riemann, .pdf
This theorem was conjectured by Legendre, Gauss, Dirichlet, Riemann, .pdfThis theorem was conjectured by Legendre, Gauss, Dirichlet, Riemann, .pdf
This theorem was conjectured by Legendre, Gauss, Dirichlet, Riemann, .pdf
 

Recently uploaded

MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
Elizabeth Walsh
 

Recently uploaded (20)

Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

3. Implement the UnsortedList class to store a list of numbers that .pdf

  • 1. 3. Implement the UnsortedList class to store a list of numbers that are input into the list from data.txt. - create a main.cpp file that gets the numbers from the file - insert the number 7 into the list - insert another number 300 into the list - delete the number 6 from the list - print out the following: --the entire list - the greatest - the least 2. There should be four files, the main.cpp, UnsortedList.cpp, ItemType.h, and the output file two called outfile2.txt - Yes you need to make your program output an "outfile2.txt" Contents of “data.txt 10 8 250 800 -1 6 Solution main.cpp: #include #include #include #include int main () { std::list mylist; std::list::iterator it; std::fstream myfile("data.txt"); std::ofstream myfile1("output2.txt"); int a; while (myfile >> a) { mylist.push_back(a); } it = mylist.begin();
  • 2. std::cout << ' '; std :: cout << "Initial List:"; for (it=mylist.begin(); it!=mylist.end(); ++it) std::cout << ' ' << *it; std::cout << ' '; std::cout << ' '; std :: cout << "Insert 7:"; mylist.insert (it,7); for (it=mylist.begin(); it!=mylist.end(); ++it) std::cout << ' ' << *it; std::cout << ' '; std::cout << ' '; std :: cout << "Intest 300:"; mylist.insert (it,300); for (it=mylist.begin(); it!=mylist.end(); ++it) std::cout << ' ' << *it; std::cout << ' '; std::cout << ' '; std :: cout << "Delete 6:"; mylist.remove(6); for (it=mylist.begin(); it!=mylist.end(); ++it) std::cout << ' ' << *it; std::cout << ' '; std::cout << ' '; std::cout << "Final list:"; for (it=mylist.begin(); it!=mylist.end(); ++it) std::cout << ' ' << *it; myfile1 << *it << std::endl; std::cout << ' '; std::cout << ' '; return 0; } UnsortedList.cpp: #include #include #include
  • 3. #include int main () { std::list mylist; std::list::iterator it; std::fstream myfile("output2.txt"); int a; int largest; while (myfile >> a) { mylist.push_back(a); } it = mylist.begin(); for (it=mylist.begin(); it!=mylist.end(); ++it) if (*it>largest){ largest=*it; } std::cout <<"Largest is:"; std::cout <