Difference between revisions of "Solução: Problema do conjunto e seus elementos únicos (Bruno Barbosa)"
From AdonaiMedrado.Pro.Br
Line 28: | Line 28: | ||
if(*(k+i)!=*(k+i-1)) | if(*(k+i)!=*(k+i-1)) | ||
printf("%d\n", *(k+i)); | printf("%d\n", *(k+i)); | ||
− | |||
} | } | ||
</code> | </code> |
Latest revision as of 16:45, 3 July 2009
#include <stdio.h> #include <stdlib.h> int comparar(const void *a, const void *b) { return *(int *)a-*(int *)b; } int main(){ int i, n; scanf("%d", &n); int k[n]; for(i=0;i<n;i++) scanf("%d", k+i); printf("\n"); qsort(k, n, sizeof(int), comparar); printf("%d\n", *k); for(i=1;i<n;i++) if(*(k+i)!=*(k+i-1)) printf("%d\n", *(k+i)); }