-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprac3.c
More file actions
46 lines (37 loc) · 780 Bytes
/
prac3.c
File metadata and controls
46 lines (37 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//remove duplicate in int array
#include<stdio.h>
int main(){
int n;
scanf("%d", &n);
int arr[n];
for(int i=0;i<n;i++){
scanf("%d", &arr[i]);
}
int count=0,temp;
for(int i=0;i<n;i++){
if(arr[i]!='\0'){
temp=arr[i];
}
for(int j=i+1;j<n;j++){
if(temp==arr[j]){
arr[j]='\0';
count++;
}
}
}
// for(int i=0;i<n;i++){
// printf("%d", arr[i]);
// }
int arr1[n-count];
int j=0;
for(int i=0;i<n-count;i++){
if(arr[j]!='\0'){
arr1[i]=arr[j];
j++;
}
}
for(int i=0;i<n-count;i++){
printf("%d ", arr1[i]);
}
printf("Size= %d", n-count);
}