Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- char processarComandos(string comandos)
- {
- char resp[] = {'N','O','S','L'};
- int direcao = 0;
- int proxEstado = 0;
- for(int i=0; i<comandos.length(); i++)
- {
- direcao = !((int)comandos[i] & 1) * 180 + 90;
- proxEstado = (proxEstado + direcao) % 360;
- }
- return resp[ proxEstado / 90 ];
- }
- int main()
- {
- int numComandos = 0;
- string comandos;
- cin>>numComandos;
- while(numComandos > 0)
- {
- cin>>comandos;
- char r = processarComandos(comandos);
- cout<<r<<"\n";
- cin>>numComandos;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement