-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLonely Integer
More file actions
62 lines (52 loc) · 1.03 KB
/
Copy pathLonely Integer
File metadata and controls
62 lines (52 loc) · 1.03 KB
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
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
int max(int arr[],int n)
{
int location,maximum,c;
maximum = INT_MIN;
for (c = 0; c < n; c++)
{
if (arr[c] > maximum)
{
maximum = arr[c];
location = c+1;
}
}
return arr[location-1];
}
int lonelyinteger(int a_size, int* a) {
int i;
int n=max(a,a_size);
//printf("%d\n",n);
int c[n];
for(i=0;i<=n;i++)
c[i]=0;
for(i=0;i<a_size;i++)
c[a[i]]=c[a[i]]+1;
/*for(i=0;i<=n;i++)
printf("%d",c[i]);
printf("\n");*/
for(i=0;i<=n;i++){
if(c[i]==1)
printf("%d",i);
}
return 0;
}
int main() {
int res;
int _a_size, _a_i;
scanf("%d", &_a_size);
int _a[_a_size];
for(_a_i = 0; _a_i < _a_size; _a_i++) {
int _a_item;
scanf("%d", &_a_item);
_a[_a_i] = _a_item;
}
res = lonelyinteger(_a_size, _a);
// printf("%d", res);
return 0;
}