Title description
The user name and password for a software system login is (user name: admin; password: admin). The user enters the user name and password to determine whether the login is successful.
Input:
Multiple sets of test data, each line has two strings separated by spaces, the first is the user name, and the second is the password.
Output:
Multiple sets of test data, each output a string ("Login Success!" or "Login Fail!").
Sample Input
admin login
admin admin
abc abc
Sample Output
Login Fail!
Login Success!
Login Fail!
Ideas
This question is to compare the input string with the string given by the title to see if the same is different. If the two strings are the same, output Login Success! Otherwise output Login Fail!
C++ code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
char str1[1000], str2[1000], str3[1000] = "admin";;
while(cin >> str1 >> str2)
{
int flag = 0;
if(strcmp(str1, str3) == 0)
{
if(strcmp(str2, str3) == 0)
{
cout << "Login Success!" << endl;
flag = 1;
}
}
if(flag == 0) cout << "Login Fail!" << endl;
}
return 0;
}