#include <iostream.h>
#include <stdlib.h>
void main()
{
char ch1,ch2,ch3,ch4,ch5,ch6,rh1,rh2,rh3,rh4,rh5,rh6;
int j = 0;
do
{
cout << "请输入自设密码:" << endl ;
// cin.clear(); //清除错误标志位
cin >> ch1 >> ch2 >> ch3 >> ch4 >> ch5 >> ch6;
cout << endl ;
cout << "请再次输入密码以校验:" << endl;
// cin.clear(); //清除错误标志位
cin >> rh1 >> rh2 >> rh3 >> rh4 >> rh5 >>rh6;
if ( rh1 != ch1 || rh2 != ch2 || rh3 != ch3 || rh4 != ch4 || rh5 != ch5 || rh6 != ch6 )
cout << "两次密码不一致,请再次输入" << endl;
else
{
j = 1 ;
break ;
}
}while ( !j );
int i = 1;
while ( i++ <= 3)
{
cout << "请输入密码" <<endl;
cin >> ch1 >> ch2 >> ch3 >> ch4 >> ch5 >>ch6;
cout << endl ;
}
if ( rh1 != ch1 || rh2 != ch2 || rh3 != ch3 || rh4 != ch4 || rh5 != ch5 || rh6 != ch6 )
{
if ( i < 4 )
cout << "密码不正确,请在此输入:" << endl ;
else
{
cout << "对不起,您三次没有输对密码" << endl ;
exit ( 0 ) ;
}
}
else
{
cout << "密码正确,请进入下一步操作" << endl ;
}
}
|