fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. bool isspecial (char c) {
  6. return (c == '!' || c == '"' || c == '#' ||
  7. c == '$' || c == '%' || c == '&' ||
  8. c == '+' || c == '(' || c == ')' ||
  9. c == '*' || c == '\'');
  10. }
  11.  
  12. int main() {
  13. char password[101];
  14. cin >> password;
  15. bool test_lc, test_uc, test_dig, test_sp,
  16. test_len = strlen(password) >= 8;
  17. int length = strlen(password);
  18. test_lc = test_uc = test_dig = test_sp = false;
  19. for (int i = 0; i < length; i++) {
  20. if (!test_lc) test_lc = islower(password[i]);
  21. if (!test_uc) test_uc = isupper(password[i]);
  22. if (!test_dig) test_dig = isdigit(password[i]);
  23. if (!test_sp) test_sp = isspecial(password[i]);
  24. }
  25. cout << test_len + test_lc + test_uc + test_dig + test_sp;
  26. return 0;
  27. }
Success #stdin #stdout 0s 15232KB
stdin
1aA
stdout
3