Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<map>
- #include<vector>
- #include<stdio.h>
- using namespace std;
- int main()
- {
- int t,n,i,j,k=0;
- int a[11][11];
- cin>>t;
- while(k<t)
- {
- cin>>n;
- int op;
- for(i=0;i<n;i++){
- for(j=0;j<n;j++)
- cin>>a[i][j];
- }
- cin>>op;
- while(op>0)
- {
- string s;
- int temp,c,d;
- cin>>s;
- if(s=="row")
- {
- cin>>c>>d;
- for(i=0;i<n;i++)
- {
- temp=a[c-1][i];
- a[c-1][i]=a[d-1][i];
- a[d-1][i]=temp;
- }
- }
- else if(s=="col")
- {
- cin>>c>>d;
- for(i=0;i<n;i++)
- {
- temp=a[i][c-1];
- a[i][c-1]=a[i][d-1];
- a[i][d-1]=temp;
- }
- }
- else if(s=="inc")
- {
- for(i=0;i<n;i++)
- for(j=0;j<n;j++)
- a[i][j]=(a[i][j]+1)%10;
- }
- else if(s=="dec")
- {
- for(i=0;i<n;i++)
- for(j=0;j<n;j++)
- a[i][j]=(a[i][j]+9)%10;
- }
- else if(s=="transpose")
- {
- int b[11][11];
- for(i=0;i<n;i++)
- for(j=0;j<n;j++)
- {
- b[j][i]=a[i][j];
- }
- for(i=0;i<n;i++){
- for(j=0;j<n;j++)
- a[i][j]=b[i][j];
- }
- }
- op--;
- }
- printf("Case #%d\n",k+1);
- for(i=0;i<n;i++){
- for(j=0;j<n;j++)
- cout<<a[i][j];
- cout<<endl;
- }
- cout<<endl;
- k++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment