C + + array-transpose of matrices

Source: Internet
Author: User

//Transpose of the matrix//swaps a two-dimensional array row and column elements into another two-dimensional array. //For example//a=1 2 3//4 5 6//b=1 4//2 5//3 6//The procedure is as follows:#include <iostream>using namespacestd;intMain () {inta[2][3]={{1,2,3},{4,5,6}}; intb[3][2],i,j; cout<<"Array A:"<<Endl;  for(i=0;i<2; i++)    {         for(j=0;j<3; j + +) {cout<<a[i][j]<<" "; B[j][i]=A[i][j]; } cout<<Endl; } cout<<"Array B:"<<Endl;  for(i=0; i<=2; i++)    {         for(j=0; j<=1; j + +) cout<<b[i][j]<<" "; cout<<Endl; } System ("PAUSE");//pause, press any key to continue, system function call    return 0;}

C + + array-transpose of matrices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.