Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. string k, s1="",s;
  5. vector<string>vc,temp;
  6. int n, ar[5][5];
  7.  
  8. void rotateleft(){
  9. temp;
  10. for(int j=n-1; j>=0; j--){
  11. s1="";
  12. for(int i=0; i<n; i++){
  13. if(vc[i][j]=='v')s1+='>';
  14. else if(vc[i][j]=='>')s1+='^';
  15. else if(vc[i][j]=='^')s1+='<';
  16. else if(vc[i][j]=='<')s1+='v';
  17. else s1+=vc[i][j];
  18. }
  19. temp.push_back(s1);
  20. }
  21. vc=temp;
  22. temp.clear();
  23. }
  24.  
  25. void rotateright(){
  26. temp;
  27. for(int j=0; j<n; j++){
  28. s1="";
  29. for(int i=n-1; i>=0; i--){
  30. if(vc[i][j]=='v')s1+='<';
  31. else if(vc[i][j]=='>')s1+='v';
  32. else if(vc[i][j]=='^')s1+='>';
  33. else if(vc[i][j]=='<')s1+='^';
  34. else s1+=vc[i][j];
  35. }
  36. temp.push_back(s1);
  37. }
  38. vc=temp;
  39. temp.clear();
  40. }
  41.  
  42. int main(){
  43. cin >> n>>k;
  44. for(int i=1; i<=n; i++){
  45. cin>>s;
  46. vc.push_back(s);
  47. }
  48. for(int i=0; i<k.size(); i++){
  49. if(k[i]=='R')rotateright();
  50. else rotateleft();
  51. }
  52. for(int i=0; i<n; i++){
  53. cout<<vc[i]<<endl;
  54. }
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement