forked from knchapagai/ProgrammingHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasswordCheck.cpp
45 lines (39 loc) · 1.02 KB
/
passwordCheck.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Problem Link : https://www.codechef.com/problems/PASSWD
code :
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ll t;
cin >> t;
while(t--){
string s;
cin >> s;
int l = s.length();
int lc=0,uc=0,dc=0,sc=0;
for(int i=0;i<l;i++){
if(s[i]>='a' and s[i]<='z'){
lc++;
}
else if((s[i]>='A' and s[i]<='Z') and (i!=0 and i!=(l-1))){
uc++;
}
else if(s[i]>='0' and s[i]<='9' and (i!=0 and i!=(l-1))){
dc++;
}
else if((s[i]=='@' or s[i]=='#' or s[i]=='%' or s[i]=='&' or s[i]=='?') and (i!=0 and i!=l-1) ){
sc++;
}
}
if(l>=10 and (lc>=1 and uc>=1 and dc>=1 and sc>=1)){
cout << "YES" << "\n";
}
else{
cout << "NO" << "\n";
}
}
return 0;
}