fork download
  1. #include<stdio.h>
  2. #include<stdbool.h>
  3. int main() {
  4. int n;
  5. scanf("%d",&n);
  6. int a[n];
  7. bool check[100000];
  8. for(int i=0; i<=n-1;i++) {
  9. scanf("%d", &a[i]);
  10. check[a[i]] = true;
  11. }
  12. int dem;
  13. bool ok = false;
  14. for(int i=0; i<n-1; i++) {
  15. dem = 1;
  16. if(check[a[i]]){
  17. for(int j=i+1; j<n; j++) {
  18. if(a[i] == a[j]){
  19. dem++;
  20. ok = true;
  21. }
  22. }
  23. }
  24. check[a[i]] = false;
  25. if(dem>1){
  26. printf("%d ",a[i]);
  27. }
  28. }
  29. if(!ok)
  30. printf("0");
  31. return 0;
  32. }
Success #stdin #stdout 0s 5540KB
stdin
Standard input is empty
stdout
Standard output is empty