I tried to do the homework which was to add code to show the shortest path but it is not working can you help.
#include
using namespace std;
int main(){
char ch;
ch=cin.get();
int x=0;
int y=0;
while(ch!='\n'){
if(ch=='n' or ch=='N')
y++;
else if(ch=='e' or ch=='E')
x++;
else if(ch=='s' or ch=='S')
y--;
else
x--;
ch=cin.get();
}
cout<<"The coordinates are: "<<x<<" "<<y<<endl;
while(ch!='\n'){
if(x>0){
for(int i=0;i<x;i++)
cout<<"E";
}
else if(x<0){
for(int i=0;i>x;i++)
cout<<"W";
}
else if(y>0){
for(int i=0;i<y;i++)
cout<<"N";
}
else{
for(int i=0;i>y;i++)
cout<<"S";
}
ch=cin.get();
}
}