language: C (gcc-4.7.2)
date: 759 days 11 hours ago
link:
visibility: public
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
#include <stdio.h>
 
void dupes(int a[], int n)
{
    int i;
 
    for (i = 0; i < n; i++)
        while (a[a[i]] != a[i]) {
            int tmp = a[i];
            a[i] = a[tmp];
            a[tmp] = tmp;
        }
 
    for (i = 0; i < n; i++)
        if (a[i] != i)
            printf("%d ", a[i]);
 
    printf("\n");
}
 
int main()
{
    int x[] = {1, 2, 3, 1, 3, 0, 6};
 
    dupes(x, sizeof x / sizeof x[0]);
    return 0;
}
 
  • upload with new input
  • result: Success     time: 0s    memory: 1720 kB     returned value: 0

    3 1