Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. //#include <fstream>
  3. using namespace std;
  4. //ifstream fin("matrice7.in");
  5. //ofstream fout("matrice7.out");
  6.  
  7. int main()
  8. {
  9. int n,m,a[101][101],s[101]={0};
  10. cin>>n>>m;
  11. for(int i=1;i<=n;i++)
  12. for(int j=1;j<=m;j++)
  13. {
  14. cin>>a[i][j];
  15. s[i]+=a[i][j];
  16. }
  17. for(int i=1;i<n;i++)
  18. for(int j=i+1;j<=n;j++)
  19. {
  20. if(s[i]>s[j])
  21. {
  22. swap(s[i],s[j]);
  23. for(int k=1;k<=m;k++)
  24. swap(a[i][k],a[j][k]);
  25. }
  26. }
  27. for(int i=1;i<=n;i++)
  28. {
  29.  
  30. for(int j=1;j<=m;j++)
  31. cout<<a[i][j]<<" ";
  32. cout<<endl;
  33. }
  34.  
  35.  
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement