程序设计 求求帮忙看看哪错了
要求设计程序
选择服务5的时候编译器停不下来了
想问一下是这个list哪写错了吗
#include
#include
#include
#include
using namespace std;
class information {
//账户信息
private:
//信息
string accountnumber = "0123456789876543210"; //用户名
string password = "123456"; //密码
int money = 10000; //余额
public:
//操作转换
string getaccount() {
return accountnumber;
}
string getpassword() {
return password;
}
void changepassword(string new_password) {
password = new_password;
}
void addmoney(int a) {
//存款
money += a;
}
void minusmoney(int a) {
//取款
money -= a;
}
int getmoney() {
//余额查询
return money;
}
};
class atm {
//提款机类系统
public:
//信息
string my_account;//该用户的用户名
string my_password;//该用户的密码
//操作页面
void welcome();//欢迎页面
void login();//登录页面
void setpassword();//重设密码页面
void display();//显示功能页面
void input();//存款页面
void withdraw();//取款页面
void inquire();//查询余额页面
void record();//人工服务页面
void exit();//退卡页面
information person;//创立一个person用户
listputin;
listputout;
};
void atm::welcome() {
cout << "-----欢迎来到本银行------" << endl;
cout << "-----请插入银行卡-----" << endl;
cout << "(模拟插卡过程,请输入1)" << endl;
int card;
cin >> card;
if (card == 1) {
login();
} else {
cout << "卡片信息录入失败" << endl;
cout << "!!!请联系工作人员!!!" << endl;
system("pause");
}
}
void atm::login() {
cout << "----插卡成功----" << endl;
cout << "(默认用户名为0123456789876543210)(默认密码为123456)" << endl;
cout << "为了确认您的信息,请输入以下信息" << endl;
cout << "您的用户名是:";
cin >> my_account;
cout << endl;
if (my_account == person.getaccount()) {
cout << "您的密码是: ";
cin >> my_password;
cout << endl;
if (my_password == person.getpassword()) {
cout << "登录成功" << endl;
display();
} else {
cout << "密码错误!请再次输入您的密码,您还有两次输入的机会" << endl;
string my_password2;
cin >> my_password2;
if (my_password2 == person.getpassword()) {
cout << "登录成功" << endl;
display();
} else {
cout << "密码错误!请再次输入您的密码,您还有最后一次输入的机会" << endl;
string my_password3;
cin >> my_password3;
if (my_password3 == person.getpassword()) {
cout << "登录成功" << endl;
cout << "尊贵的用户您好!" << endl;
cout << "我们提供的服务如下:" << endl;
display();
} else {
cout << "密码输入全部错误,帐号冻结" << endl;
cout << "正在为您退卡" << endl;
exit();
}
}
}
} else {
cout << "查询不到您的用户名" << endl;
cout << "正在为您退卡" << endl;
exit();
}
}
void atm::display() {
cout << "1.存款 2.取款 " << endl;
cout << "3.修改密码 4.查询余额 " << endl;
cout << "5.查询存取款记录 6.退卡" << endl;
int temp;
cout << "请选择您需要的服务" << endl;
cin >> temp;
if (temp == 1) {
input();
} else if (temp == 2) {
withdraw();
} else if (temp == 3) {
setpassword();
} else if (temp == 4) {
inquire();
} else if (temp == 6) {
exit();
} else if (temp == 5) {
record();
}
}
void atm::input() {
cout << "为了保证取款环境的安全,请您再次输入您的银行卡密码" << endl;
string number;//密码
cin >> number;
if (number == person.getpassword()) {
cout << "请输入您想要存入的金额" << endl;
int deposit;//存款
cin >> deposit;
person.addmoney(deposit);
cout << "存款成功" << endl;
cout << "---返回至服务页面---" << endl;
cout << "服务项目如下:" << endl;
putin.push_front(deposit);//以便查询
display();
} else {
cout << "密码错误!请联系工作人员" << endl;
}
}
void atm::withdraw() {
cout << "为了保证取款环境的安全,请您再次输入您的银行卡密码" << endl;
string number;//密码
cin >> number;
if (number == person.getpassword()) {
cout << "请输入您想要取走的金额,提款金额仅限100的整数倍(元)" << endl;
int withdrawl;//取款金额
cin >> withdrawl;
if (withdrawl % 100 == 0) {
int temp = person.getmoney() - withdrawl;
if (temp <= 0) {
cout << "您的余额不足,无法取款" << endl;
cout << "如需继续取款请按1---如需查询余额请按2---如需返回服务页面请按3" << endl;
int button;//模拟按键
cin >> button;
if (button == 1) {
withdraw();
} else if (button == 2) {
inquire();
} else if (button == 3) {
display();
}
} else {
person.minusmoney(withdrawl);
cout << "取款成功" << endl;
cout << "---返回至服务页面---" << endl;
cout << "服务项目如下:" << endl;
putout.push_front(withdrawl);//取款查询
display();
}
} else if (withdrawl % 100 != 0) {
cout << "您输入的金额无法取款 返回至服务页面" << endl;
display();
}
} else {
cout << "密码错误!请联系工作人员" << endl;
exit();
}
}
void atm::inquire() {
//输出保留两位小数
cout << "您的账户目前的余额是:" << fixed << setprecision(2) << person.getmoney() << endl;
cout << "查询余额结束" << endl;
cout << "---返回至服务页面---" << endl;
cout << "服务项目如下:" << endl;
display();
}
void atm::setpassword() {
cout << "请输入您想设置的密码:";
string code;//密码
cin >> code;
cout << endl;
person.changepassword(code);
cout << "请确认您的密码:";
string codeagain;
cin >> codeagain;
if (codeagain == person.getpassword()) {
cout << "您的新密码设置成功";
cout << "---返回至服务页面---" << endl;
cout << "服务项目如下:" << endl;
display();
} else {
cout << "您再次输入的密码不正确" << endl;
setpassword();
}
}
void atm::record() {
cout << "存取款情况如下:" << endl;
cout << "存款情况: ";
list::iterator it1 = putin.begin();
while (it1 != putin.end()) {
cout << *it1 << "元" << " ";
++it1;
}
cout << endl;
cout << "取款情况: ";
list::iterator it2 = putout.begin();
while (it1 != putout.end()) {
cout << *it2 << "元" << " ";
++it2;
}
cout << endl;
cout << "查询存取款记录结束" << endl;
cout << "---返回至服务页面---" << endl;
cout << "服务项目如下:" << endl;
display();
}
void atm::exit() {
cout << "退卡成功" << endl;
system("pause");
}
int main() {
atm personsatm;
personsatm.welcome();
}
选择服务5的时候编译器停不下来,可能是服务5对应代码有问题
编译器停不下来,可能是死循环,所以题主知道哪出问题了吗?