Advertisement
Spocoman

04. Password Guess

Sep 1st, 2023 (edited)
1,672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string password;
  7.     cin >> password;
  8.  
  9.     if (password == "s3cr3t!P@ssw0rd") {
  10.         cout << "Welcome" << endl;
  11.     }
  12.     else {
  13.         cout << "Wrong password!" << endl;
  14.     }
  15.  
  16.     return 0;
  17. }
  18.  
  19. Решение с тернарен оператор:
  20.  
  21. #include <iostream>
  22.  
  23. using namespace std;
  24.  
  25. int main() {
  26.     string password;
  27.     cin >> password;
  28.  
  29.     cout << (password == "s3cr3t!P@ssw0rd" ? "Welcome" : "Wrong password!") << endl;
  30.    
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement