fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. void sorting(vector<int>& a){
  6. sort(a.begin(),a.end());
  7. }
  8. int main() {
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0);
  11. ll n;
  12. cin>>n;
  13. vector<int> a(n);
  14. for(int i=0;i<n;i++){
  15. cin>>a[i];
  16.  
  17. sorting(a);
  18. for(int k=0;k<n;k++){
  19. if(a[k]==a[k+1]){
  20. cout<<a[k]<<" ";
  21. }
  22. }
  23. }
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5440KB
stdin
2
8
1 3 2 3 4 6 5 5 
10
1 5 2 8 1 4 7 4 3 6 
stdout
Standard output is empty