fork download
  1. #include <iostream>
  2. #include <stdexcept>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. string password;
  8. bool validPassword = false;
  9.  
  10. while (!validPassword) {
  11. try {
  12. cin >> password;
  13.  
  14. if (password.length() < 8) {
  15. throw runtime_error("Invalid");
  16. }
  17.  
  18. validPassword = true;
  19. cout << "Accepted" << endl;
  20. }
  21. catch (runtime_error& excpt) {
  22. cout << "Error: " << excpt.what() << endl;
  23. }
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5288KB
stdin
banana58
stdout
Accepted