样例过了,0分求调

B3843 [GESP202306 三级] 密码合规

Youmh @ 2024-10-03 20:28:14

#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  string book[109];
  int cnt = 0;
  int t = 0;
  for(int i = 0;i < a.size();i++){
    if(a[i] == ','){
      cnt++;
      book[cnt] = a.substr(t , i - t);
      t = i + 1;
    }
  }
  cnt++;
  book[cnt] = a.substr(t , a.size() - t);
  for(int i = 1;i <= cnt;i++){
    bool flag = true;
    if(book[i].size() > 12 || book[i].size() < 6) continue;
    int f1 = 0 , f2 = 0 , f3 = 0 , f4 = 0;
    for(int j = 0;j < book[i].size();j++){
      if(isupper(book[i][j])) f1 = 1;
      else if(islower(book[i][j])) f2 = 1;
      else if(isdigit(book[i][j])) f3 = 1;
      else if(book[i][j] == '!' || book[i][j] == '@' || book[i][j] == '#' || book[i][j] == '$') f4 = 1;
      else{
        flag = false;
        break; 
      }
    }
    if(flag == false) continue;
    if(f1 + f2 + f2 >= 2 && f4 == 1)cout<< book[i] << endl;
  }
  return 0;
}

by Youmh @ 2024-10-04 08:42:06

@ron120719


上一页 |