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
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.
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
- Question: (Related to R-language)-Looking answer to the below question. "Given a numeric vector x of arbitrary length, write code to create a vector y that contains the squares of the values of x (note: x and y will have the same length). Your solution should not involve more than a couple of lines of code" .arrow_forwardHow do you declare a vector to store double values? How do you append a double to a vector? How do you find the size of a vector? How do you remove an element from a vector?arrow_forwardDo not use AI.arrow_forward
- Don't use vector array .using ifstream and ofstream. C++ programarrow_forwardcreate a code using mathlab, make sure not used advance code. I cannot used if or return or anything more advance than that.arrow_forward(Check test scores) The answers to a true-false test are as follows: T T F F T. Given a two-dimensional answer array, in which each row corresponds to the answers provided on one test, write a function that accepts the two-dimensional array and number of tests as parameters and returns a one-dimensional array containing the grades for each test. (Each question is worth 5 points so that the maximum possible grade is 25.) Test your function with the following data: int score = 0;arrow_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_forward3) Create a function named "makeThemOdd". The function should accept a parameter named "numberArray". Use the higher order function map() to create a new array that contains all the numbers from the original parameter array but adds 1 to each even number. The new array should only have odd numbers in it. Return the new array. // Use this array to test your function:const testingArray = [1, 2, 4, 17, 19, 20, 21];arrow_forwardC++. Solution with explanation please.arrow_forward
- Q4 (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_forwardHelp Please I am trying to solve thisarrow_forwardcreate a code using mathlab, make sure not used advance code. I cannot used if or return or anything more advance than that.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