-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray_dup.c
91 lines (79 loc) · 1.87 KB
/
array_dup.c
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <stdio.h>
int main()
{
int arr[10] = {10,20,30,10,20,40,10,20,50,20};
int arr_dups[10];
int count=0;
int num=0;
for(int i=0; i<10;i++)
{
arr_dups[i] = arr[i];
}
for(int i=0; i<10; i++)
{
printf("%d\t" , arr_dups[i]);
}
for(int i=0; i<10; i++)
{
for(int j=i+1; j<10;)
{
if(arr_dups[i]> arr_dups[j])
{
int temp = arr_dups[i];
arr_dups[i] = arr_dups[j];
arr_dups[j] = temp;
j++;
}
else {
j++;
}
}
}
printf("\n");
for(int i=0; i<10; i++)
{
printf("%d\t" , arr_dups[i]);
}
printf("\n\n");
auto unsigned int i=0;
while(i<10)
{
for(int j=i+1; j<10;)
{
if(arr_dups[i] == arr_dups[j])
{
count++;
num++;
printf("Num Value is %d ===> Count Value is %d\n",num,count);
printf("Equal Numbers are arr_dups[i] %d arr_dups[j] %d\n",arr_dups[i],arr_dups[j]);
j++;
}
else
{
j++;
}
}
num = num+1;
i= num;
}
// for(int i=num; i<10; i++)
// {
// for(int j=i+1; j<10; j++)
// {
// if(arr_dups[i] == arr_dups[j])
// {
// ++count;
// ++num;
// printf("True Cond :%d and arr_dup[i] is %d and arr_dup[j] is %d\n",num,arr_dups[i],arr_dups[j]);
// }
// else
// {
// printf(" False Cond \n");
// }
// }
// printf("\ni incremented \n");
// }
printf("\nTotal Number Of Duplicates Is : %d\n" , count);
printf("Num Value Is : %d\n" , num);
return 0;
}