URI Solution 1437 Turn Left! - Solution in C++ | Ad Hoc
URI Online Judge Solution | Ad Hoc
URI Main Problem Link - 1437 Turn Left https://www.urionlinejudge.com.br/judge/en/problems/view/1437
Problem Name: URI Problem 1437 Turn Left
Problem Number : URI Problem 1437 Turn Left Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1437 Turn Left Code in CPP:
#include <iostream> using namespace std; int main() { int n; char c, dir; while(cin >> n && n != 0) { dir = 'N'; for(int i = 0; i < n; ++i) { cin >> c; if(c == 'D' && dir == 'N'){ dir = 'L'; }else if(c == 'E' && dir == 'N'){ dir = 'O'; }else if(c == 'D' && dir == 'O'){ dir = 'N'; }else if(c == 'E' && dir == 'O'){ dir = 'S'; }else if(c == 'D' && dir == 'L'){ dir = 'S'; }else if(c == 'E' && dir == 'L'){ dir = 'N'; }else if(c == 'D' && dir == 'S'){ dir = 'O'; }else{ dir = 'L'; } } cout << dir << endl; } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks