csansoon

P2.20 P79784 Movements on the ground

Sep 26th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int x=0,y=0;
  6.     char c;
  7.     while (cin >> c) {
  8.         if (c=='n') y--;
  9.         if (c=='s') y++;
  10.         if (c=='e') x++;
  11.         if (c=='w') x--;}
  12.     cout << "(" << x << ", " << y << ")" << endl;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment