矩阵的行之间交换,列之间交换


#include<iostream>
#include<algorithm>
using namespace std;
int a[505][505];
    long n,m,k;

 
int main()
{

    cin>>n>>m;
    for(int i=1;i<=n;i++) 
	  for(int j=1;j<=m;j++) 
         cin>>a[i][j];  
 	 
   // sort(a+1,a+n+1,cmp); 
    
    cin>>k;
    char ch;
    int x,y;
    for(int i=0;i<k;i++)
      {
      	 cin>>ch>>x>>y;
      	 if(ch=='Q')
      	   {
      	     cout<<a[x][y]<<endl;	 
	   }
		 if(ch=='C')
		 {
	            for(int i=1;i<=m;i++)   //x行和y行之间交换
	              {
	        	  int temp=a[x][i];
	        	  a[x][i] = a[y][i];
		          a[y][i] = temp;
		       }		    
		}
      }
     
	return 0;
}

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM