1 solutions

  • 2
    @ 2025-2-11 10:36:16
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int T;
    	cin>>T;
    	while(T--)
    	{
    		string s;
    		cin>>s;
    		int a[5]={0};
    		int n=s.size();
    		for(int i=0;i<n;i++)
    		{
    			if(s[i]>='0'&&s[i]<='9')
    			{
    				a[1]++;
    			}
    			else if(s[i]>='A'&&s[i]<='Z')
    			{
    				a[2]++;
    			}
    			else if(s[i]>='a'&&s[i]<='z')
    			{
    				a[3]++;
    			}
    			else 
    			{
    				a[4]++;
    			}
    		}
    		int cnt=0;
    		for(int i=1;i<=4;i++)
    		{
    			if(a[i]>0)
    			{
    				cnt++;
    			}
    		}
    		if(cnt==4)
    		{
    			cout<<2<<endl;
    		}
    		else if(cnt==1)
    		{
    			cout<<0<<endl;
    		}
    		else 
    		{
    			cout<<1<<endl;
    		}
    	}
        return 0;
    }
    
    • 1

    Information

    ID
    668
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    57
    Accepted
    16
    Uploaded By