2016/10/6

来源:互联网 发布:手机怎么成为网络歌手 编辑:程序博客网 时间:2024/06/11 06:11

1631-5 黄加勉 <2016.10.6>

"连续第5天总结"


namespace A. //今日任务

{

            1.类和对象(40%)

            2.字符串(50%)

}


namespace B. //具体内容

            1.感觉类和结构体有点类似

            2.现在封装才开一点头,感觉接下来会很高端…

            3.vs的字符串头文件是<string>,用<cstring>没法通过

            4.getchar();为啥有事有用有时不管用???

            5.写了个注册登录的程序…


附上代码:


#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;


class Register
{
public:
string user_name;
string password1;
string password2;
string code_objective;
string code_subjective;
};


class Login
{
public:
string user_name;
string password;
};


int main()
{
system("color F0");
while (1)
{
int num, time = 0, coor = 0;
bool temp = false, val = true, flag = true;
Register user1;
cout << "          \
注册" << endl;
cout << "用户名 : ";
cin >> user1.user_name;
cout << "密码 : ";
cin >> user1.password1;


num = user1.password1.size();
int first = (int)user1.password1[0];


if (first >= 0x41 && first <= 0x5A)
{
cout << "请再输入一遍密码 : ";
cin >> user1.password2;
cout << endl;
if (user1.password1 == user1.password2)
{
temp = true;
}
else
{
cout << "-----------[两次密码输入不一致]-----------" << endl << endl;
cout << "****************请按回车键重新填写****************" <<
endl << endl << endl << endl;
system("pause");
system("cls");
temp = false;
}


if (temp)
{
if (num < 6)
{
cout << "-----------[密码不得小于6位]-----------" << endl;
temp = true;
}
if (num >= 6 && num <= 10)
{
cout << "[密码强度:弱]" << endl;
coor = 1;
temp = false;
}
if (num >= 11 && num <= 15)
{
cout << "[密码强度:中]" << endl;
coor = 2;
temp = false;
}
if (num >= 16 && num <= 20)
{
cout << "[密码强度:强]" << endl;
coor = 3;
temp = false;
}
if (num >= 21)
{
cout << "-----------[密码不得超过20位]-----------" << endl;
temp = true;
}
cout << endl;
if (temp == true)
{
cout << "****************请按回车键重新填写****************" << endl
<< endl << endl << endl;
system("pause");
system("cls");


}


if (temp == false)
{
while (flag && time != 5)
{
user1.code_objective = "45DF2";
cout << "验证码:" << user1.code_objective << endl;
cout << "请输入验证码(有五次机会):";
cin >> user1.code_subjective;
if (user1.code_subjective == user1.code_objective)
{
flag = false;
cout << endl << endl << "<<<<<   注册成功!   >>>>>" << endl << " 回车提交注册表格" << endl << endl;
system("pause");
while (val)
{
system("cls");
Login *login = new Login();
if (NULL == login)
{
cout << "*****ERROR*****";
}
else
{
cout << "          \
登录" << endl;
cout << "用户名 : ";
cin >> login->user_name;
cout << "密码 : ";
cin >> login->password;
if ((login->user_name == user1.user_name) && (login->password == user1.password1))
{
cout << endl;
cout << "<<<<<   登录成功 !   >>>>>>" << endl;
Sleep(2500);
val = false;
system("cls");
}
else
{
cout << "用户名或密码输入错误" << endl;
system("pause");
val = true;
}
}
delete login;
login = NULL;
}
}
else
{
system("cls");
cout << "          \
注册" << endl;
cout << "用户名 : " << user1.user_name << endl;
cout << "密码 : " << user1.password1 << endl;
cout << "请再输入一遍密码 : " << user1.password1 << endl << endl;
switch (coor)
{
case 1: cout << "[密码强度:弱]" << endl; break;
case 2: cout << "[密码强度:中]" << endl; break;
case 3: cout << "[密码强度:强]" << endl; break;
}
time++;
cout << endl << "************验证码输入错误 " << time << "次" << "************" << endl << endl;
if (time == 5)
{
cout << "******请重新填写******" << endl;
Sleep(2000);
}
}
}
system("cls");
}
}

}
else
{
cout << endl << "      密码第一位必须为大写字母      " << endl << endl;
cout << "****************请按回车键重新填写****************" <<
endl << endl << endl << endl;
system("pause");
system("cls");
}
}
return 0;
}


namespace C. //明日任务
            1.弄懂怎么产生随机字符串
            2.字符串和类继续学习
0 0
原创粉丝点击