Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question
[画像:Write a C++ program that reads in three strings and sorts them lexicographically. After the sorting, print out the string in sorted order. You can't call std::sort(), of course, since that would solve the whole problem already. However, you're welcome to look up "C++ string comparison operations" and use those operations. Go through the following steps: 1. Define an array of 3 strings, called strings, in main(), like this: string strings [3]; 2. Ask the user to input 3 strings, each one on a line. Use getline (cin, strings [i]) to read the 3 strings (lines) in a for loop. 3. Write a void swap (string &, string &) function that swaps the two strings given to it as reference parameters. This should be familiar to you. 4. using if statements, string comparison operations, and your swap () function, write code that will sort the 3 strings into ascending lexicographical order. 5. Test the code on all 6 possible permutations of 3 strings, and report on the test results. Include screenshots of the terminal showing the tests. (Make sure your program is verbose enough to be clear about the inputs and outputs of your test runs.) Here a sample of the one of my 6 test runs. Note that I used one-character test strings for simplicity.]
expand button
Transcribed Image Text:Write a C++ program that reads in three strings and sorts them lexicographically. After the sorting, print out the string in sorted order. You can't call std::sort(), of course, since that would solve the whole problem already. However, you're welcome to look up "C++ string comparison operations" and use those operations. Go through the following steps: 1. Define an array of 3 strings, called strings, in main(), like this: string strings [3]; 2. Ask the user to input 3 strings, each one on a line. Use getline (cin, strings [i]) to read the 3 strings (lines) in a for loop. 3. Write a void swap (string &, string &) function that swaps the two strings given to it as reference parameters. This should be familiar to you. 4. using if statements, string comparison operations, and your swap () function, write code that will sort the 3 strings into ascending lexicographical order. 5. Test the code on all 6 possible permutations of 3 strings, and report on the test results. Include screenshots of the terminal showing the tests. (Make sure your program is verbose enough to be clear about the inputs and outputs of your test runs.) Here a sample of the one of my 6 test runs. Note that I used one-character test strings for simplicity.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY