Advertisement
Spocoman

01. Valid Usernames

Nov 21st, 2023
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string passwords, pass;
  8.     getline(cin, passwords);
  9.  
  10.     while (passwords.length() != 0) {
  11.         pass = passwords.substr(0, passwords.find(", "));
  12.         passwords.erase(0, pass.length() + 2);
  13.         bool isValid = true;
  14.         if (pass.length() > 3 && pass.length() <= 16) {
  15.             for (size_t i = 0; i < pass.length(); i++) {
  16.                 if (!isalpha(pass[i]) && !isdigit(pass[i]) && pass[i] != '-' && pass[i] != '_') {
  17.                     isValid = false;
  18.                     continue;
  19.                 }
  20.             }
  21.         }
  22.         else {
  23.             continue;
  24.         }
  25.        
  26.         if (isValid) {
  27.             cout << pass << endl;
  28.         }
  29.     }
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement