Question
#include using namespace std; void remove_duplicate(int a[], int size) { cout < < Your array after remove duplicate = { ; for (int i =
#include
using namespace std;
void remove_duplicate(int a[], int size) { cout << "Your array after remove duplicate = { "; for (int i = 0; i < size; i++) { for (int j = i + 1; j < size; j++) { if (a[i] == a[j]) { a[j] = a[j + 1]; size--; } } } for (int i = 0; i < size; i++) { cout << a[i] << " "; } cout << "}." << endl; cout << "Your new size = " << size << endl; } int main() { int size = 0; float value; int array[20]; char repeat; do { cout << "Please enter your array (Q/q to stop) = "; while (cin >> value) { if (cin.fail()) { break; } array[size] = value; size++; } cin.clear(); cin.ignore(); cout << "Your array is = { "; for (int i = 0; i < size; i++) { cout << array[i] << " "; } cout << "}. " << endl; cout << "Your array size is = " << size << endl; remove_duplicate(array, size); cout << "Do you want continue (y/n): "; cin >> repeat; } while (repeat == 'y'); cout << "Exit!" << endl; system("Pause"); return 0; }
what's wrong whit it? all way missing the last value and don't count the last value.
How to fix it ?
Please enter your array (Q/q to stop) =14916974911q Your array is ={14916974911}. Your array size is =9 Your array after remove duplicate ={149167}. Your new size =5 Do you want continue (y/n)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started