Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. ifstream fin("mat.in");
  8.  
  9. int n,m;
  10.  
  11. int main()
  12. {
  13.  
  14. cin >> n >> m;
  15.  
  16. int a[n][m],b[n*m],nr=0;
  17.  
  18. for(int i=0;i<n;i++)
  19. for(int j=0;j<m;j++)
  20. {
  21. cin >> a[i][j];
  22. b[nr++]=a[i][j];
  23. }
  24.  
  25. for(int i=0;i<nr-1;i++)
  26. for(int j=i+1;j<nr;j++)
  27. if(b[i]>b[j])
  28. swap(b[i],b[j]);
  29.  
  30. for(int i=0;i<nr;i++)
  31. cout << b[i] << " ";
  32.  
  33. return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement