C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 7.14E
Program Plan Intro
1.int a[10] used as a input array
2.
3. noduplicates function used to remove the duplicate elements in an array.
Expert Solution & Answer
Trending nowThis is a popular solution!
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
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.
- Write a function that takes a vector and returns the maximum element.
- Same as above, but without using the "max" function.
Chapter 7 Solutions
C++ How to Program (10th Edition)
Ch. 7 - Exercises 7.6(Fill in the Blanks) Fill in the...Ch. 7 - (True or False) Determine whether each of the...Ch. 7 - (Write C++ Statements) Write C++ statements to...Ch. 7 - (Two-Dimensional array Questions) Consider a...Ch. 7 - (Salesperson Salary Ranges) Use a one-dimensional...Ch. 7 - (One-Dimensional array Questions) Write statements...Ch. 7 - (Find the Errors) Find the error(s) in each of the...Ch. 7 - (Duplicate Elimination with array) Use a...Ch. 7 - Prob. 7.14ECh. 7 - Prob. 7.15E
Ch. 7 - (Dice Rolling) Write a program that simulates...Ch. 7 - ( What Does This Code Do?) What does the following...Ch. 7 - (Craps Game Modification) Modify the program of...Ch. 7 - (Converting vector Example of Section 7.10 to...Ch. 7 - Prob. 7.20ECh. 7 - (Sales Summary) Use a two-dimensional array to...Ch. 7 - (Knight's Tour) One of the more interesting...Ch. 7 - (Knight's Tour: Brute Forty Approaches ) In...Ch. 7 - (Eight Queens) Another puzzler for chess buffs is...Ch. 7 - (Eight Queens: Brute Force Approaches) In this...Ch. 7 - Prob. 7.26ECh. 7 - (The Sieve of Eratosthenes) A prime integer is any...Ch. 7 - Prob. 7.28RECh. 7 - (Eight Queens) Modify the Eight Queens program you...Ch. 7 - (Print an array) Write a recursive function...Ch. 7 - Prob. 7.31RECh. 7 - Prob. 7.32RECh. 7 - (Maze Traversal) The grid of hashes (#) and dots...Ch. 7 - Prob. 7.34RECh. 7 - Making a Difference 7.35 (Polling) The Internet...
Knowledge Booster
Similar questions
- Do not use AI.arrow_forwardDon't use vector array .using ifstream and ofstream. C++ programarrow_forward"""3. Write a function validSolution/ValidateSolution/valid_solution()that accepts a 2D array representing a Sudoku board, and returns trueif it is a valid solution, or false otherwise. The cells of the sudokuboard may also contain 0's, which will represent empty cells.Boards containing one or more zeroes are considered to be invalid solutions.The board is always 9 cells by 9 cells, and every cell only contains integersfrom 0 to 9. (More info at: http://en.wikipedia.org/wiki/Sudoku)""" # Using dict/hash-tablefrom collections import defaultdict def valid_solution_hashtable(board): for i in range(len(board)): dict_row = defaultdict(int) dict_col = defaultdict(int) for j in range(len(board[0])): value_row = board[i][j] value_col = board[j][i] if not value_row or value_col == 0: return False if value_row in dict_row: return False else: dict_row[value_row] += 1.arrow_forward
- Question 5 Write a function that receives a vector of integers and an integer. Your function should return the index of where the integer was found in the vector or a -1 if it was not found.arrow_forwardGroup B Q1) A vector is given by x = [-3.5-5 6.2 11 0 8.1-903-132.5]. Using conditional statements and loops, write a program that creates two vectors from x-one (call it P) that contains the positive elements of x, and a second (call it N) that contains the negative elements of x. In both P and N, the elements are in the same order as in x.arrow_forwardQ1/ Write a function that calculates the mean of the input vector?arrow_forward
- C++. Solution with explanation please.arrow_forwardUSING C++ Program Specifications: Write a program to calculate the minimum, maximum, mean, median, mode, and whether a vector is a palindrome. Step 0. Review the starter code in main(). A vector is filled with integers from standard input. The first value indicates how many numbers are to follow and be placed in the vector. Step 1. Use a loop to process each vector element and output the minimum and maximum values. Submit for grading to confirm one test passes. Ex: If the input is: 6 4 1 5 4 99 17 the output is: Minimum: 1 Maximum: 99 Step 2. Use a loop to sum all vector elements and calculate the mean (or average). Output the mean with one decimal place using cout << fixed << setprecision(1); once before all other cout statements. Submit for grading to confirm two tests pass. Ex: If the input is: 6 4 1 5 4 99 17 the output is: Minimum: 1 Maximum: 99 Mean: 21.7 Step 3. Use a loop to determine if the vector is a palindrome, meaning values are the same from front to back and…arrow_forwardQ4 (Intro to R+ If statements + Functions) Q4: Create a function 'strictly_increase' that takes a vector with length of 3, and checks if the elements of the vector are strictly increasing. If so, return True. Otherwise, return False. e.g., strictly increase(c(1,2,3)) TRUE e.g., strictly_increase(c(1,2,1)) FALSEarrow_forward
- Using R software, create a function that returns the square root of a vector x. However, it uses a tryCatch statement so that if x has negative numbers, then it returns x as it is and issues a warning that x contains negative numbers. Otherwise, it returns the square root of xarrow_forward[ ] [] power In the cell below, you are to write a function "power(list)" that takes in a list as its input, and then returns the power set of that list. You may assume that the input will not have any duplicates (i.e., it's a set). After compiling the above cell, you should be able to compile the following cell and obtain the desired outputs. print (power ( ["A", "B"]), power ( ["A", "B", "C"])) + Code + Markdown This should return [[], ["A"], ["B"], ["A", "B"]] [[], ["A"], ["B"], ["C"], ["A", "B"], ["A", "C"], ["B", "C"], ["A", "B", "C"]] (the order in which the 'sets' appear does not matter, just that they are all there) Python Pythonarrow_forwardMatch (std::array member function on left with the correct description on right. Hint: You might want to look this up here . fill at begin empty swap [Choose ] [Choose ] returns an iterator pointing to the first element in the array container. returns a direct reference to the first element in the array container. returns a const_iterator pointing to the first element in the array container. set all the values in the array with the parameter passed. check whether array is empty. returns a reference to the element at position, i passed as the parameter. exchanges the content of the array by the content of another array object of the same type and the same size. [Choose ] [Choose ] >arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education