userNAME

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string mi1,mi2;//password pwd
	cout<<"Please enter your user password"<<endl;
	getline(cin,mi1);
	cout<<"Please enter it again"<<endl;
	getline(cin,mi2);
	
	string zuimi;
	if(mi1==mi2)
	//the same
	{
		 
		zuimi =  mi1;
		int a1 = 0,a2 = 0,a3 = 0,a4 = 0;
		//判断密码强度
		
		for(int i=0;zuimi[i]!='\0';i++)//无限模式
		{
			if(zuimi[i]>='0'&&zuimi[i]<='9')//如果是数字
			a1=1;
            
			else if(zuimi[i]>='a'&&zuimi[i]<='z')//如果是小写字母
			a2=1;
            
			else if(zuimi[i]>='A'&&zuimi[i]<='Z')//如果是大写字母
			a3=1;
            
			else//特殊符号
			a4=1;
		}		
		
		if(a1+a2+a3+a4==1)//如果只有一种的话,那么只有1
		cout<<endl<<"Low password strength"<<endl<<endl;
       
		else if(a1+a2+a3+a4==2||a1+a2+a3+a4==3)/*两种或三种*/
		cout<<endl<<"Medium password strength"<<endl<<endl;
        		
		else if(a1+a2+a3+a4==4)//如果有4种
		cout<<endl<<"Passwords are strong"<<endl<<endl;	
	}
	
	else
	// different
	{
		for(;;)
		{
			cout<<"The two inputs before and after are not the same, please cooperate again"<<endl<<endl<<endl;
			cout<<"Please enter your user password"<<endl;
			getline(cin,mi1);
			cout<<"Please enter it again"<<endl;
			getline(cin,mi2);
			if(mi1==mi2)
			{
				zuimi =  mi1;
				int a1 = 0,a2 = 0,a3 = 0,a4 = 0;
				//判断密码强度
		
				for(int i=0;zuimi[i]!='\0';i++)//无限模式
				{
					if(zuimi[i]>='0'&&zuimi[i]<='9')//如果是数字
					a1=1;
            
					else if(zuimi[i]>='a'&&zuimi[i]<='z')//如果是小写字母
					a2=1;
            
					else if(zuimi[i]>='A'&&zuimi[i]<='Z')//如果是大写字母
					a3=1;
            
					else//特殊符号
					a4=1;
				}		
		
				if(a1+a2+a3+a4==1)//如果只有一种的话,那么只有1
				cout<<endl<<"Low password strength"<<endl<<endl;
       
				else if(a1+a2+a3+a4==2||a1+a2+a3+a4==3)/*两种或三种*/
				cout<<endl<<"Medium password strength"<<endl<<endl;
        		
				else if(a1+a2+a3+a4==4)//如果有4种
				cout<<endl<<"Passwords are strong"<<endl<<endl;	
			}
			break;	
		}
	}	
	
	string hua;
	cout<<"Okay, now you can type some arbitrary words into it."<<endl;
	getline(cin,hua);
	
	for(int i=1;i<=2;i++) cout<<endl;
	for(;;)
	{
		string pan;
		cout<<"Now you want to look at the words you just wrote"<<endl<<endl<<"Please enter YES or NO"<<endl;
		getline(cin,pan);
		if(pan=="YES"||pan=="yes")
		{
			for(int i=1;i<=5;i++)
			{
				cout<<"To make sure you're not a robot, we'll output a verification code, and ask you to follow the input"<<endl;
				
				int yanzheng = (rand()%9+0)+(rand()%9+0)*1000+(rand()%9+0)*100+(rand()%9+0)*10+(rand()%9+0);
				cout<<yanzheng<<endl;
	
				int pan_zheng;
				cin>>pan_zheng;
	
				if(pan_zheng==yanzheng) break;
				else
				{
					cout<<"Please re-enter"<<endl;
					continue;
				}
				if(i==5)
				{
					cout<<"Due to the number of input errors you make, the program will end";
					return 0;
				}
			}
			break;
		}	
		else
		{
			if(pan=="NO"||pan=="no") return 0;
		}
	}
	int panduan_shifo = 0;
	for(int i=1;i<=1;i++)
	{
		cout<<"Please enter your user password"<<endl;
		getline(cin,mi1);
		if(mi1==zuimi) break;
		else
		{
			panduan_shifo++;
			for(int i=1;i<=4;i++)
			{
				cout<<"Please enter again, and you only have "<<5-i<<" chances"<<endl;
				getline(cin,mi1);
				if(mi1==zuimi) break;
				else
				{
					panduan_shifo++;
					continue;
				}
			}
		}
	}
	cout<<endl<<endl;
	if(panduan_shifo==5)
	{
		cout<<"Since you have entered the wrong password too many times, we suspect that it is not you who entered the password; So the program will be closed"<<endl;
		return 0;
	}
	else cout<<hua;
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值