Created
October 31, 2015 18:42
-
-
Save elizabet92/06852eca4f01b2a3e141 to your computer and use it in GitHub Desktop.
Problem1 - Points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main() | |
{ | |
int x, y, flag = 1; | |
char array[1000]; | |
cout<<"Enter X-coordinate:"; | |
cin>>x; | |
cout<<"Enter Y-coordinate:"; | |
cin>>y; | |
cout<<"Enter instruction string:"; | |
cin>>array; | |
for(int i=0; array[i]!='\0'; i++) | |
{ | |
switch(array[i]) | |
{ | |
case '<': x-=flag; break; | |
case '>': x+=flag; break; | |
case '^': y-=flag; break; | |
case 'v': y+=flag; break; | |
case '~': flag=-flag; break; | |
default: break; | |
} | |
} | |
cout<<x<<" "<<y; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment