//注意正确密码 用户名初始化赋值的格式
AC代码:
#include <stdio.h>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
char name[12];
gets(name);
char code[20];
char x[20] = { '0' };
char password[20] = {'1','2','3','4','5','6'};
while (gets(code))
{
if (strcmp(code, x) == 0)
{
cout << "Wrong Password!";
break;
}
else if (strcmp(code, password) == 0)
{
cout << "Hello " << name;
break;
}
else
{
cout << "Wrong Password!" << endl;
}
}
//system("pause");
return 0;
}
编写程序模拟简单的密码登录(正确的密码是123456),首先从键盘输入用户名(用户名随意,不超过10个字符)