PASSWD - Editorial

Can you tell how we can do it by regular expression ?

I not able to form correct expression

#include<bits/stdc++.h>
#include
#include<string.h>
#define ll long long
using namespace std;
bool check(char a)
{
int x=int(a);
if(x>=97 && x<=122)
{
return true;
}
return false;
}
int main()
{
int t=1;
cin>>t;
while(t–)
{
string s;
cin>>s;
if(s.length()<10)
{
cout<<β€œNO\n”;
continue;
}
int n=s.length();
bool upper=false;
bool lower=false;
bool sp=false;
bool dig=false;
for(int i=0;i<n;i++)
{
int a=int(s[i]);
if(a>=65 && a<=90 && i!=0 && i!=n-1)
{
upper=true;
}
if(check(s[i]))
{
lower=true;
}
if((s[i]-β€˜0’)>=0 && (s[i]-β€˜0’)<=9 && i!=0 && i!=n-1)
{
dig=true;
}
if(s[i]==’@’ || s[i]==’#’ || s[i]==’%’ || s[i]==’&’ || s[i]==’?’ && i!=0 && i!=n-1)
{
sp=true;
}
}
if(upper && lower && dig && sp)
{
cout<<β€œYES\n”;
continue;
}
cout<<β€œNO”<<endl;
}
return 0;
}

What wrong in this