是个初中生,技术不怎么样,所以就想用int和if else做一个简易的登录程序。
但是代码看了好几遍都没有问题,测试的时候不输入指定的密码也会达到输入密码的效果。
下面是源代码:
#include
#include<stdio.h>
using namespace std;
int main()
{
float a; //这里我是想设定密码的变量为a
cout<<"Please enter your password:"<<endl;
cin>>a;
if (a=52141314){//我设定的密码是52141314
cout<<"The password is right!"<<endl;
} else {
cout<<"The password is wrong!"<<endl;
};
return 0;
}
这只是第一种,我也试过if(a!=52141314),也失败了。
有没有人指点指点?属于是智商不够用了。
if (a = 52141314)烧写一个“=”,应该是a == 52141314