I want all adjacent duplicates. Like, if the input is 1 3 3 4 5 5 6 6 2, the program should print 3 5 6. I've tried moving stuff around but I can't get the output I want. Not sure if I'm missing something or my logic is wrong. Thanks in advance. :)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double input;
double previous;
cout << "Please enter a series of numbers : ";
cin >> previous;
while (cin >> input)
{
if (input == previous)
{
input ++;
}
cout << "The duplicate inputs are: "<< input << endl;
previous = input;
}
#include <iostream>
usingnamespace std;
int main()
{
int i = 0;
int arr[100];
int size;
cout << "How many numbers would you like to enter ";
cin >> size;
cin.ignore();
for (i = 0; i < size; i++)
{
cout << "Enter a number ";
cin >> arr[i];
cin.ignore();
cout << endl;
}
for (i = 0; i < size - 1; i++)
{
if (arr[i] == arr[i + 1])
cout << "Duplicate number " << arr[i] << endl;
}
cin.ignore();
return 0;
}