1 answer

Write a function named "eliminate_duplicates" that takes an array of integers in random order and eliminates...

Question:

Write a function named "eliminate_duplicates" that takes an array of integers in random order and eliminates all the duplicate integer integers in the array. The function should take two arguments: (1) an array of integers; (2) an integer that tells the number of cells in the array. The function should return the number of distinct integers in the array.


Answers

#include <iostream>
using namespace std;
int eliminateDuplicates(int array[], int size);
int main()
{
const int MAX_SIZE = 10;
int numSeq[MAX_SIZE] = { 1, 3, 5, 7, 9, 10, 7, 12, 13, 7};
int result;
result = eliminateDuplicates(numSeq, MAX_SIZE);
cout << endl << "Result is " << result << " numbers." << endl;
return 0;
}
int eliminateDuplicates(int array[], int size)
{
int *dataBuffer = new int[size];
int dataCount = 0;
bool found = false;
memset(dataBuffer, 0, sizeof(int)*size);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
if (array[i] == dataBuffer[j])
found = true;
if (!found)
{
dataBuffer[dataCount] = array[i];
dataCount++;
}
found = false;
}
for (int i = 0; i < dataCount; i++)
cout << dataBuffer[i] << " ";
delete[] dataBuffer;
return dataCount;
}

.

Similar Solved Questions

1 answer
Select the best answer for the question 3. Koogle Corporation uses residual income to evaluate the...
Select the best answer for the question 3. Koogle Corporation uses residual income to evaluate the performance of its divisions. The company's minimum required rate of return is 13%. In August, the commercial products division had average operating assets of $530,000 and net operating income of ...
1 answer
The Schrodinger equation for a particle in a ring can be expressed as H cap psi(phi)...
The Schrodinger equation for a particle in a ring can be expressed as H cap psi(phi) = E psi(phi), where H cap = -h^2 partial^2/21 partial phi^2; psi(phi) = 1/squareroot 2 pi e^-ik phi, k is an integer What is the potential energy? What is the kinetic energy? Write the Schrodinger equation Derive th...
1 answer
Assume that a simple random sample has been selected and test the given claim. Use the...
Assume that a simple random sample has been selected and test the given claim. Use the P-value method for testing hypotheses. Identify the null and alternative hypotheses, test statistic, P-value, and state the final conclusion that addresses the origina The ages of actresses when they won an acting...
1 answer
Let G be the graph ei U1 e2 and consider the walk V111221 (a) Can this...
Let G be the graph ei U1 e2 and consider the walk V111221 (a) Can this walk be written unambiguously as V1 V2V1? O Yes O No If this walk cannot be written unambiguously, select the walk that V1VzVcould equally refer to, but is different than vierzez 1 OviezV21V1 OeVie2291 OeVie1422 O vze.V1212 The w...
1 answer
& 8.3.37 Question Help A major airline recently began encouraging reservation agents to nap durin...
& 8.3.37 Question Help A major airline recently began encouraging reservation agents to nap during their breaks. The table to the right lists the number of complaints received about each of a sample of 8 reservation agents during the 6 months before naps were encouraged and during the 6 months a...
1 answer
The trial balance of My Motor, Inc. on March 1, 20XX, lists the entity’s assets, liabilities,...
The trial balance of My Motor, Inc. on March 1, 20XX, lists the entity’s assets, liabilities, and owner’s equity on that date. Balance Account Title Debit Credit Cash 26,000 Accounts receivable 4,500 Accounts payable 2,000 Common Stock 20,500 ...
2 answers
Find the exact circumference of a circle with diameter equal to 8 ft
Find the exact circumference of a circle with diameter equal to 8 ft. I know the answer is 25 ft but the answers I have to choose from are 8, 16 or 64...
1 answer
On January 2, 2016, Pet Retreat purchased fixtures for $35,500 cash, expecting the fixtures to remain...
On January 2, 2016, Pet Retreat purchased fixtures for $35,500 cash, expecting the fixtures to remain in service for five years. Pet Retreat has depreciated the fixtures on a straight-line basis, with $7,000 residual value. On April 30, 2018, Pet Retreat sold the fixtures for $17,700 cash. Record bo...
1 answer
15) Angular Velocity. (4 pts.) A small and a large wheel are connected by a belt....
15) Angular Velocity. (4 pts.) A small and a large wheel are connected by a belt. The small wheel is turned at a constant angular velocity ml How does the angular velocity of the large wheel a compare to that of the small wheel?...
1 answer
How do you simplify #6 1/2 div 2 1/3#?
How do you simplify #6 1/2 div 2 1/3#?...
1 answer
Suppose that the average waiting time for a patient at a physician's office is just over...
Suppose that the average waiting time for a patient at a physician's office is just over 29 minutes. In order to address the issue of long patient wait times, some physicians' offices are using wait- tracking systems to notify patients of expected wait times. Patients can adjust their arriva...
1 answer
Solve the problem ONLY 2 QUESTIONS answer and get full points SHOW ALL WORK
Solve the problem and answer the question.15. Paddleboat ride, In the Mississippi river near new orleans, the Creole Queen paddleboat travels 6 miles upstream (against the current) in the same amount of timeit travels 12 miles downstream (with the current). If the current of the river is 3 miles per...
1 answer
An art gallery has contacted you for help. An artist is planning to create an aluminum...
An art gallery has contacted you for help. An artist is planning to create an aluminum sculpture formed from a single piece of sheet metal. Find its center of gravity. 3 in 5 in 6 in. Sin. r = 2.25 in....
1 answer
LOVE UCIUL RR di 0 dation on an expansion strategy? EMENT. 05.15 ACTIVITY-BASED COSTING AND ACTIVITY-BASED...
LOVE UCIUL RR di 0 dation on an expansion strategy? EMENT. 05.15 ACTIVITY-BASED COSTING AND ACTIVITY-BASED MANAGEMENT, AUTOMOTIVE SUPPLIER O'Sullivan Company is an automotive component supp O'Sullivan has been approached by Honda Canada's Alliston, Ontario, plant to conside expanding its...
1 answer
Given #f(x)=1/8x-3# and #g(x)=x^3#, how do you find #(f^-1og^-1)(1)#?
Given #f(x)=1/8x-3# and #g(x)=x^3#, how do you find #(f^-1og^-1)(1)#?...
1 answer
Questions 20 , 21 , 22 Acct 102 Practice Test #5.pdf Download ?Info ×Close Page >...
questions 20 , 21 , 22 Acct 102 Practice Test #5.pdf Download ?Info ×Close Page > of 13 ZOOM Dashboa 20 A company has a minimum required rate of return of 10% and is considering investing in a project that requires an investment of 1968,000 and is expected to generate cash inflows of $84,00...
1 answer
Write the Matlab code to model and generate the surfaces using boundaries. Question given below is...
Write the Matlab code to model and generate the surfaces using boundaries. Question given below is to be solved using matlab Determine the point on the bilinear surface defined by P(0,0)=[0 0 1], P(0,1)=[1 1 1],P(1,0)=[1 0 0],P(1,1)=[0 1 0], corresponding to u=v=0.5 in parametric space....