#include
using namespace std;
int main()
{
char ch,s=’ ‘;
int x=0,y=0;
ch = cin.get();
while(ch!=’\n’)
{
if(ch=='E' or ch=='e')
{
x++;
}
else if(ch=='W' or ch=='w')
{
x--;
}
else if(ch=='N' or ch=='n')
{
y++;
}
else
{
y--;
}
ch = cin.get();
}
while(x!=0 and y!=0)
{
if(x>0)
{
s+='E';
x--;
}
if(x<0)
{
s+='W';
x++;
}
if(y>0)
{
s+='N';
y--;
}
if(y<0)
{
s+='S';
y++;
}
}
cout<<"final displacement is "<< s;
return 0;
}
WHY I am not getting the x and y units in terms of NSEW??.