fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int m,n;
  7. cin>>m>>n;
  8. int a[m],b[n];
  9. for(int i=0;i<m;i++)
  10. {
  11. cin>>a[i];
  12. }
  13. for(int j=0;j<n;j++)
  14. {
  15. cin>>b[j];
  16. }
  17. sort(a,a+m);
  18. sort(b,b+n);
  19. for(int i=0;i<m;i++)
  20. {
  21. cout<<a[i]<<" ";
  22. }
  23. cout<<"\n";
  24. for(int j=0;j<n;j++)
  25. {
  26. cout<<b[j]<<" ";
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 5488KB
stdin
4
1 2 4 2
7
2 1 4 7 2 4 4
stdout
2 2 4 7 
2