c++中,如何在bool型函数的for循环中返回bool的值?
booljudging(stringaccountnumber,stringpassword){for(inti=0;i<cusnum;i++){if(database[...
bool judging(string accountnumber,string password)
{
for (int i=0; i<cusnum; i++) {
if (database[i][0]==accountnumber) {
if (database[i][1]==password){
cout << "Welcome to XX Bank!"
<< "here is your account balance:" << endl;
;
}
else
cout << "ERROR!" <<
"The password is not match to the account.";
break;
}
else if(database[i][0]!=accountnumber && i==cusnum-1)
{
cout << "ERROR! Please enter the account again:";
break;
}
}
}
以上是我的代码,我想要在accountnumber和password中任意一个不匹配的情况下把函数的返回值输出成false,否则则为true,应该怎么做呢?谢谢! 展开
{
for (int i=0; i<cusnum; i++) {
if (database[i][0]==accountnumber) {
if (database[i][1]==password){
cout << "Welcome to XX Bank!"
<< "here is your account balance:" << endl;
;
}
else
cout << "ERROR!" <<
"The password is not match to the account.";
break;
}
else if(database[i][0]!=accountnumber && i==cusnum-1)
{
cout << "ERROR! Please enter the account again:";
break;
}
}
}
以上是我的代码,我想要在accountnumber和password中任意一个不匹配的情况下把函数的返回值输出成false,否则则为true,应该怎么做呢?谢谢! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询