Skip to content

Instantly share code, notes, and snippets.

@elizabet92
Created October 31, 2015 18:42
Show Gist options
  • Save elizabet92/06852eca4f01b2a3e141 to your computer and use it in GitHub Desktop.
Save elizabet92/06852eca4f01b2a3e141 to your computer and use it in GitHub Desktop.
Problem1 - Points
#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