Maruf_Hasan

uva 11360

Aug 30th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #include<iostream>
  2. #include<map>
  3. #include<vector>
  4. #include<stdio.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int t,n,i,j,k=0;
  10. int a[11][11];
  11. cin>>t;
  12. while(k<t)
  13. {
  14. cin>>n;
  15. int op;
  16. for(i=0;i<n;i++){
  17. for(j=0;j<n;j++)
  18. cin>>a[i][j];
  19. }
  20. cin>>op;
  21. while(op>0)
  22. {
  23. string s;
  24. int temp,c,d;
  25. cin>>s;
  26.  
  27. if(s=="row")
  28. {
  29. cin>>c>>d;
  30. for(i=0;i<n;i++)
  31. {
  32. temp=a[c-1][i];
  33. a[c-1][i]=a[d-1][i];
  34. a[d-1][i]=temp;
  35. }
  36. }
  37. else if(s=="col")
  38. {
  39. cin>>c>>d;
  40. for(i=0;i<n;i++)
  41. {
  42. temp=a[i][c-1];
  43. a[i][c-1]=a[i][d-1];
  44. a[i][d-1]=temp;
  45. }
  46. }
  47. else if(s=="inc")
  48. {
  49. for(i=0;i<n;i++)
  50. for(j=0;j<n;j++)
  51. a[i][j]=(a[i][j]+1)%10;
  52. }
  53. else if(s=="dec")
  54. {
  55. for(i=0;i<n;i++)
  56. for(j=0;j<n;j++)
  57. a[i][j]=(a[i][j]+9)%10;
  58. }
  59. else if(s=="transpose")
  60. {
  61. int b[11][11];
  62. for(i=0;i<n;i++)
  63. for(j=0;j<n;j++)
  64. {
  65. b[j][i]=a[i][j];
  66.  
  67. }
  68. for(i=0;i<n;i++){
  69. for(j=0;j<n;j++)
  70. a[i][j]=b[i][j];
  71. }
  72. }
  73.  
  74.  
  75. op--;
  76. }
  77. printf("Case #%d\n",k+1);
  78. for(i=0;i<n;i++){
  79. for(j=0;j<n;j++)
  80. cout<<a[i][j];
  81. cout<<endl;
  82. }
  83. cout<<endl;
  84. k++;
  85. }
  86.  
  87. return 0;
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment