Last active
January 2, 2016 20:19
-
-
Save KT-Yeh/8355813 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <map> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
map<string,string>m; | |
char line[200]; | |
while(gets(line)){ | |
if (line[0]=='\0') break; | |
char a[50],b[50]; | |
sscanf(line,"%s %s",a,b); | |
m[b]=a; | |
} | |
while(gets(line)){ | |
if (line[0]=='\0') break; | |
if (m[line]=="\0") //map如果沒對應到,其內容為"\0" | |
printf("eh\n"); | |
else | |
printf("%s\n",m[line].c_str()); //把C++字串換回C字串 | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment