Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <map>
- using namespace std;
- int main(){
- map<string,string> m;
- m["Apple"] = "0930999666";
- m["Ben"] = "0945875421";
- m["Candy"] = "0932542151";
- string name;
- cin >> name;
- cout << m[name] << endl;
- /*
- C:
- char name[100][20], phone[100][20];
- strcpy( name[0], "Apple" );
- strcpy( phone[0], "0930999666" );
- char input[20];
- scanf("%s", input);
- for( int i = 0 ; i < 1 ; i++ ){
- if( strcmp(input, name[i]) == 0 ){
- printf("%s\n", phone[i]);
- break;
- }
- }
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment