



#include "head.h"
#include <stdio.h>
using namespace std;
void registerUser(vector<string>& number,vector<string>& passwd){
string username;
string Passwd;
cout << "请输入账号:" << endl;
cin >> username;
cout << "请输入密码:" << endl;
cin >> Passwd;
typename vector<string>::iterator it = number.begin();
for(it;it!=number.end();it++)
{
if(*it==username)
{
cout << "账号已存在" << endl;
return;
}
}
number.push_back(username);
passwd.push_back(Passwd);
cout << "注册成功" << endl;
}
void login(vector<string>& number,vector<string>& passwd){
string username;
string Passwd;
cout << "请输入账号:" << endl;
cin >> username;
cout << "请输入密码:" << endl;
cin >> Passwd;
typename vector<string>::iterator it1 = number.begin();
typename vector<string>::iterator it2 = passwd.begin();
for(it1,it2;it1!=number.end();it1++,it2++)
{
if(*it1==username && *it2==Passwd){
cout << "登陆成功" << endl;
return;
}
}
cout << "账号密码有误" <<endl;
return;
}
int main(int argc, const char *argv[])
{
vector<string> number;
vector<string> passwd;
int ch;
while(1){
cout << "1.注册" << endl;
cout << "2.登录" << endl;
cout << "3.退出" << endl;
cout << "请选择操作" << endl;
cin >> ch;
switch(ch){
case 1:
registerUser(number,passwd);
break;
case 2:
login(number,passwd);
break;
case 3:
cout << "=================退出系统====================" << endl;
return 0;
default:
cout << "无效选择" << endl;
}
}
return 0;
}