Write a C++ program to find and print all unique elements of a given array of integers
- برمجة سي بلس بلس
- برمجة
- 2021-05-13
- MarwaMohammed
الأجوبة
#include <iostream>
using namespace std;
int main()
{
int array1[] = {1, 5, 7, 5, 8, 9, 11, 11, 2, 5, 6};
int s1 = sizeof(array1)/sizeof(array1[0]);
cout << "Original array: ";
for (int i=0; i < s1; i++)
cout << array1[i] <<" ";
cout <<"\nUnique elements of the said array: ";
for (int i=0; i<s1; i++)
{
int j;
for (j=0; j<i; j++)
if (array1[i] == array1[j])
break;
if (i == j)
cout << array1[i] << " ";
}
return 0;
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
