C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 7, Problem 7.14E
Program Plan Intro

Program Plan:

1.int a[10] used as a input array
2. vectornumused to remove duplicates using push_backfuction
3. noduplicates function used to remove the duplicate elements in an array.

Blurred answer
Students have asked these similar questions
- (Minimum and Maximum) We often want to find the minimum and maximum values in a vector as well as the indices at which these values occur. For this problem do not use the built in min or max function (or any other function which trivializes the problem). min_max Function: Input variables: • a vector representing the list of numbers; you may assume each value is unique Output variables: • a scalar representing the minimum value • a scalar representing the index where minimum value is located in the list • a scalar representing the maximum value • a scalar representing the index where maximum value is located in the list A possible sample case is: » [min_val, min_i, max_val, max_i] = min_max(1:5) min_val = 1 min_i max_val = max_i = 1 5 » [min_val, min_i, max_val, max_i] = min_max([2, 3, 7, 1, 4]) min_val = 1 min_i 4 max_val = max_i = 3 7 » [min_val, min_i, max_val, max_i] = LXX_QYY([1, 2, 3, 4, -1, 0]) min_val = -1 min_i max_val = %3D 4 max_i = 4
Function: randOps Input: (1xN double) A Vector of numbers (N>=2 and even) Output: (double) A number Function Description: Given a 1XN vector where N>=2 and even, perform the following random operations in the following order and return the resulting number 1. Extract all even indexed values into a vector and multiply them by 3 2. Extract all odd indexed values into a vector and divide by 5 3. Subtract the results of Step 2 from the results of Step 1. 4. Calculate the product of all the values contained in the vector result of Step 3. 5. Calculate the value needed to get the number from Step 4 to the next highest integer. 6. Round your result from Step 5 to 5 decimal places Hint(s): ▪ prod(), ceil() and round() may be Examples: ans1 = randOps ([2 5 4 1 3 4 2 1]) >>ans1 = 0.9632 ans2 = randOps ([3 6 2 5]) >> ans2 = 0.9600 ans3 = randOps ([30 40 10 20 50 80]) >> ans3 = 0
Answer in C++ code please! (Duplicate Elimination with vector) Use a vector to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the vector only if it isn't a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Begin with an empty vector and use its push_back function to add each unique value to the vector.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education