阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明] 本程序中预设了若干个用户名和
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明]
本程序中预设了若干个用户名和口令。用户输入正确的用户名后,可以查找对应的口令,一旦输入结束标记“end”,程序结束。
[C++程序]
include <iostream. h>
include <string. h>
class User
{ protected:
char user[10];
char pass[7];
public:
User(char[ ],char[]);
(1) {return user;}
(2) {return pass;}
};
User::User(char u[],char p[])
{ strcpy(user,u);
strcpy(pass,p); }
void main()
{ User ua[]={User("Li","123456"),User("wang","654321"),User("Song","666666")
char name[10];
while(1)
cout< < "输入用户名:";
cin> >name;
if((3)= =0) break;
for(int i=0;i<3;i+ +)
if(strcmp(name,ua[i].getuser()) = =0){
cout< <"密码:" < < ua[i].getpass() < <endl;
(4);
if((5))cout< <"该用户不存在!" < <endl;
}
}