201: Find and print first repeating element in array
// Find and print all unique elements of a given array of integers
#include <iostream>
using namespace std;
int main()
{
int size;
cout << "Enter the size of array: ";
cin >> size;
int array[size];
for (int i = 0; i < size; i++)
{
cout << "Enter a string for index " << i << ": ";
cin >> array[i];
}
system("cls");
cout << "First repeating element is: ";
for (int i = 0; i < size; i++)
{
for (int j = i + 1; j < size; j++)
{
if (array[i] == array[j])
{
cout << array[i];
exit(0);
}
}
}
return 0;
}
Comments
Post a Comment