Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Output: James Q2Write a C++ program that reads a list of words from a text file into a vector of strings, sorts the words in

image text in transcribedimage text in transcribed

image text in transcribed

Output:

James

Q2Write a C++ program that reads a list of words from a text file into a vector of strings, sorts the words in descending alphabetical order, and then writes the sorted list to another text file. Assume that both the input and output files are formatted with only one word on each line. An example file input/file output pair is provided below: Input file: Output file: Jim Ted Ted Raachel Paula Paula Helen Jim Rachel Helen Hint: You may use bubble sort (from lecture or selection sort (from homework 3). However, you must rewrite the sorting algorithm to work on a vector of strings. Note: You must write your code in a source file named sort list.cpp. In your code, you must read from a text file named list in.txt and write to a text file named list_out.txt. You are provided an example input text file to test your code. Use the string and vector types that are accessible when you include and , respectively. Use file input and output streams to read from and write to the files (make sure to include )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Describe performance management.

Answered: 1 week ago