include
include<stdio.h>
include<string.h>
include
using namespace std;
const char* dirs="NESW";
map <char,int >dir_map;
int dir_id(char c){return strchr(dirs,c)-dirs;}
int main()
{
int dir_id(char c);
cout<<"N在字符串中的位置是"<<dir_id('N')<<endl;
cout<<"E在字符串中的位置是"<<dir_id('E')<<endl;
cout<<"S在字符串中的位置是"<<dir_id('S')<<endl;
cout<<"W在字符串中的位置是"<<dir_id('W')<<endl;
cout<<"------------分割线-------------"<<endl;
dir_map['N']=0;
dir_map['E']=1;
dir_map['S']=2;
dir_map['W']=3;
cout<<"N的映射是"<<dir_map['N']<<endl;
cout<<"E的映射是"<<dir_map['E']<<endl;
cout<<"S的映射是"<<dir_map['S']<<endl;
cout<<"W的映射是"<<dir_map['W']<<endl;
return 0;
}