Problem:

암호 관리 응용프로그램을 map을 이용하여 작성하라.

실행 과정은 다음과 같다.

Execution Result:

Objective & Hints:

map 컨테이너에 삽입 및 조회 응용

이름과 점수를 쌍으로 저장할 맵 컨테이너로 map<string, string>을 이용하면 됩니다.

아래 링크에 있는 Exercise Problem 10장 13번을 참고하세요.

2020/03/11 - [C++/명품 C++ programming] - 명품 C++ programming Exercise Problem 10장 13번

[명품 C++ programming Exercise Problem 10장 13번

Problem: map 컨테이너를 이용하여 (이름, 성적)을 저장하고 이름으로 성적을 조회하는 점수 관리 프로그램을 만들어라. 이름은 빈칸 없이 입력하는 것을 원칙으로 한다. Execution Result: Objective & Hints: map 컨테이너..

sobamemil.tistory.com](https://sobamemil.tistory.com/123)

Code:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 #include #include using namespace std; void insert(map<string, string> &pwManager){ string name, pw; cout << "이름 암호>> "; cin >> name >> pw; pwManager.insert(make_pair(name, pw)); } void checkNamePw(map<string, string> &pwManager){ string name, pw; cout << "이름? "; cin >> name; while(true){ cout << "암호? "; cin >> pw; if(pwManager[name] == pw){ cout << "통과!!\n"; break; } else cout << "실패~~\n"; // 틀리면 출력 후 다시 암호 질문 } } int main() { map<string, string> pwManager; cout << "***** 암호 관리 프로그램 WHO를 시작합니다 *****\n"; while(true){ cout << "삽입:1, 검사:2, 종료3>> "; int n; cin >> n; switch(n){ case 1: insert(pwManager); break; case 2: checkNamePw(pwManager); break; case 3: cout << "프로그램을 종료합니다..."; return 0; } } }

Explanation:

Exercise Problem 10장 13번 문제와 비슷한 문제입니다.

참고하여 작성하면 도움이 될 것 같습니다.