You are on page 1of 2

9/4/2019 Online C Compiler - Online C Editor - Run C Online - Online C Runner

Sponsored: Segment Send data to any tool without having to implement a new API every time. Get started

C
Project Name: Distinct elements in an array perfect
1 #include<stdio.h>
2 int main()
3 {
4 int i,n,j,distinct;
5 scanf("%d",&n);
6 int a[n];
7 for(i=0;i<n;i++)
8 {
9 scanf("%d",&a[i]);
10
11 }
12 for(i=0;i<n;i++)
13 {
14 distinct=0;
15 for(j=0;j<i;j++)
16 {
17 if(a[i]==a[j])
18 {
19 distinct=1;
20 break;
21 }
22 }
23 if(distinct==0)
24 printf("%d ",a[i]);
25
26 }/*
27 ip: 5
28 1 2 3 2 3
29 op: 1 2 3
30 */
31 }

   Execute Mode, Version, Inputs & Arguments

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

You might also like