Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- char arr[1005][1005];
- string s;
- int n;
- void rotateleft()
- {
- char temp[1005][1005];
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- {
- if(arr[i][j]== 'v')
- temp[n-j-1][i]='>';
- else if(arr[i][j]== '>')
- temp[n-j-1][i]='^';
- else if(arr[i][j]== '<')
- temp[n-j-1][i]='v';
- else if(arr[i][j]== '^')
- temp[n-j-1][i]='<';
- else
- temp[n-j-1][i]=arr[i][j];
- }
- }
- for(int i=0; i<n; i++)
- for(int j=0; j<n; j++)
- arr[i][j]=temp[i][j];
- }
- void rotateright()
- {
- char temp[1005][1005];
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- {
- if(arr[i][j]== 'v')
- temp[j][n-i-1]='<';
- else if(arr[i][j]== '>')
- temp[j][n-i-1]='v';
- else if(arr[i][j]== '<')
- temp[j][n-i-1]='^';
- else if(arr[i][j]== '^')
- temp[j][n-i-1]='>';
- else
- temp[j][n-i-1]=arr[i][j];
- }
- }
- for(int i=0; i<n; i++)
- for(int j=0; j<n; j++)
- arr[i][j]=temp[i][j];
- }
- int main()
- {
- cin>>n>>s;
- for(int i=0; i<n; i++)
- for(int j=0; j<n; j++)
- cin>>arr[i][j];
- for(int i=0; i<s.size(); i++)
- {
- if(s[i]=='R')
- rotateright();
- else rotateleft();
- }
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- cout<<arr[i][j];
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement