Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is whats in nums.txt 7 0 8 3 0 7 9 2| 0 2 9 6 0 5 0| 0 0 6 1 3

image text in transcribed

this is whats in nums.txt

7 0 8 3 0 7 9 2|

0 2 9 6 0 5 0|

0 0 6 1 3 2 0 9 5 4|

1. 1 0 0 0 8 2|

6 8 3 8 8 4 2|

0 0 0 0 0|

4 0 3 0 8 0 9 0 2 0 4 0|

0 2 0 3 0 5 0 1|

1. 2 3 4 5 0 0|

9 0 3|

Compact Vector Assignment A list of integers is transformed into compact form by moving all instances of O as far to the right as possible while preserving the order of the other numbers. For example, given integers, 5 160830705, the compact form is, 5 1683 75000. Your task is to write a program to perform this transformation. The input file contains 10 lines of integers, but each line contains a different number of integers. At the end of each line is a '' to help you determine when a line is finished. The program should display the transformed version of this list in the console. Use the file called nums.txt. You must include the following functions: print()takes a vector of integers as a parameter and prints each element separated by a space and a new line at the end process()takes a vector of integers as a parameter and returns a new vector of integers that holds the original vector in compact form In the main method, I would suggest creating one vector of integers. After reading one line into this vector, you should process it and print the resulting vector. Make sure to clear the original vector after each line. When reading the 'T' characters, I would use fin.get() and fin.putback() like we did in the example from class. Output to include with cpp file: 7 8 3 79200 2 9 6 5 0 0 0 6 1 3 2 9 5 4 000 1 1 8 2 0 0 6 8 3 8 8 4 2 4 3 8 9 2 4 OOOOOO 12 3 5 1 0 0 0 0

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

Students also viewed these Databases questions