32 lines
746 B
C
32 lines
746 B
C
|
/*
|
||
|
* C Program to Print all the Repeated Numbers with Frequency in an Array
|
||
|
*/
|
||
|
#include <stdio.h>
|
||
|
#include <malloc.h>
|
||
|
|
||
|
void duplicate(int array[], int num)
|
||
|
{
|
||
|
int *count = (int *)calloc(sizeof(int), (num - 2));
|
||
|
int i;
|
||
|
printf("duplicate elements present in the given array are ");
|
||
|
for (i = 0; i < num; i++)
|
||
|
{
|
||
|
if (count[array[i]] == 1)
|
||
|
printf(" %d ", array[i]);
|
||
|
else
|
||
|
count[array[i]]++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int array[] = {5, 10, 10, 2, 1, 4, 2};
|
||
|
int array_freq = sizeof(array) / sizeof(array[0]);
|
||
|
duplicate(array, array_freq);
|
||
|
getchar();
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
|
||
|
duplicate elements present in the given array are 10 2
|