Advertisement
STANAANDREY

transpusa_mat

May 29th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. int matrix[100][100],n,i,j,m;
  7. cout<<"n=";cin>>n;
  8. cout<<"m=";cin>>m;
  9. for (i=0;i<n;i++)
  10. for (j=0;j<m;j++)
  11. cin>>matrix[i][j];
  12. //transpunere
  13. int n_t,m_t,matrix_t[100][100];
  14. n_t=m;
  15. m_t=n;
  16. for (i=0;i<n_t;i++)
  17. for (j=0;j<m_t;j++)
  18. matrix_t[i][j]=matrix[j][i];
  19.  
  20. for (i=0;i<n_t;i++) {
  21. for (j=0;j<m_t;j++)
  22. cout<<matrix_t[i][j]<<' ';
  23. cout<<endl;
  24. }
  25.  return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement