Problem:
다음은 프로그램과 Execution Result를 보여준다.
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; } } |
Execution Result:

Objective & Hints:
조작자 작성 연습
Code:
|
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include #include using namespace std; istream& prompt(istream& ins) { // prompt 조작자 cout << "암호?"; return ins; } int main() { string password; while(true) { cin >> prompt >> password; if(password == "C++") { cout << "login success!!" << endl; break; } else cout << "login fail. try again!!" << endl; } } |
](