Professional Documents
Culture Documents
Sponsored: Segment Send data to any tool without having to implement a new API every time. Get started
C
Project Name: Duplicates in an Array
1 #include<stdio.h>
2 int main()
3 {
4 int n,i,j,count=1;
5 scanf("%d",&n);
6 int a[n];
7 for(i=0;i<n;i++)
8 {
9 scanf("%d",&a[i]);
10 }
11 for(i=0;i<n;i++)
12 {
13 for(j=i+1;j<n;j++)
14 {
15 if(a[i]==0)
16 continue;
17 if(a[i]==a[j])
18 {
19 count++;
20 a[j]=0;
21 }
22 }
23 if(count>1)
24 printf("%d--%d\n",a[i],count);
25 count=1;
26
27 }
28
29 }
CommandLine Arguments
Stdin Inputs
Result
https://www.jdoodle.com/c-online-compiler/ 1/2
9/4/2019 Online C Compiler - Online C Editor - Run C Online - Online C Runner
https://www.jdoodle.com/c-online-compiler/ 2/2