fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int tee;
  7. cin>>tee;
  8. while(tee--)
  9. {
  10. int n,i,j;
  11. cin>>n;
  12. int a[n];
  13. for( i=0;i<n;i++)
  14. {
  15. cin>>a[i];
  16. }sort(a,a+n);
  17. for( i=0;i<n;i++)
  18. {
  19. //for(j=i+1;j<n;j++)
  20.  
  21. if(a[i]==a[i+1])
  22. {
  23. cout<<a[i]<<" ";
  24. }
  25.  
  26. }
  27. cout<<endl;
  28. }
  29. // your code goes here
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5548KB
stdin
2
8
1 3 2 3 4 6 5 5 
10
1 5 2 8 1 4 7 4 3 6 
stdout
3 5 
1 4