💻 개발 & CSC++ 프로그래밍

명품 C++ programming 실습 문제 11장 10번

문제 : 다음은 프로그램과 실행 결과를 보여준다. prompt 조작자를 작성하여 프로그램을 완성하라. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include #include using namespace std; int main() { string password; while(true) { cin >> prompt >> password; if(password == "C++") { cout << "login success!!" << endl; break; } else cout << "login fail. try again!!" << endl; } } 실행 결과 : ...

2020년 4월 2일 · 1 분 · Sobamemil
💻 개발 & CSC++ 프로그래밍

명품 C++ programming 실습 문제 11장 9번

문제 : 다음은 Phone 클래스이다. 1 2 3 4 5 6 7 8 9 10 11 class Phone { // 전화 번호를 표현하는 클래스 string name; string telnum; string address; public: Phone(string name="", string telnum="", string address="") { this->name = name; this->telnum = telnum; this->address = address; } }; Phone 클래스의 객체를 입출력하는 아래 코드와 실행 결과를 참조하여 <<, >> 연산자를 작성하고 Phone 클래스를 수정하는 등 프로그램을 완성하라. ...

2020년 4월 2일 · 2 분 · Sobamemil
💻 개발 & CSC++ 프로그래밍

명품 C++ programming 실습 문제 10장 15번

문제 : vector를 이용하여 아래 Circle 클래스의 객체를 삽입하고 삭제하는 프로그램을 작성하라. 삭제 시에는 이름이 같은 모든 원을 삭제한다. 1 2 3 4 5 6 7 8 9 10 class Circle { string name; // 이름 int radius; // 반지름 public: Circle(int radius, string name) { this->radius = radius; this->name = name; } double getArea() { return 3.14*radius*radius; } string getName() { return name; } }; 실행 결과 : ...

2020년 3월 11일 · 2 분 · Sobamemil
💻 개발 & CSC++ 프로그래밍

명품 C++ programming 실습 문제 10장 14번

문제 : 암호 관리 응용프로그램을 map을 이용하여 작성하라. 실행 과정은 다음과 같다. 실행 결과 : 목적 및 힌트 : map 컨테이너에 삽입 및 조회 응용 이름과 점수를 쌍으로 저장할 맵 컨테이너로 map<string, string>을 이용하면 됩니다. 아래 링크에 있는 실습 문제 10장 13번을 참고하세요. 코드 : 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; } } } 설명 : ...

2020년 3월 11일 · 2 분 · Sobamemil