Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <iostream>
- #include <cstdlib>
- #include <string>
- #include <vector>
- #define DEBUGG freopen("f:\\in.txt", "rt", stdin);freopen("f:\\out.txt", "wt, "stdout");
- #define SF scanf
- #define PF printf
- #define TESTCASE int t;scanf("%d", &t);getchar();while(t--)
- #define FOR(n) for(int i = 0; i < n; i++)
- #define N 100000
- using namespace std;
- int main()
- {
- //DEBUGG
- string main_str, comp_str;
- int tc = 1;
- int t;
- scanf("%d", &t);
- getchar();
- while(t--)
- {
- cin >> main_str >> comp_str;
- //cout << main_str << ' ' << comp_str << endl;
- PF("Case %d: ", tc++);
- int main_len = main_str.size();
- int comp_len = comp_str.size();
- if(comp_len > main_len)
- {
- //PF("
- PF("Wrong password.\n");
- }
- else if(main_len == comp_len)
- {
- if(main_str == comp_str) cout << "Login successful." << endl;
- else
- {
- bool flag = true;
- for(int i = 0; i < main_len; i++)
- {
- if((tolower(main_str[i]) != tolower(comp_str[i])) ||
- ((main_str[i] >= 'a' && main_str[i] <= 'z') && (comp_str[i] >= 'a' && comp_str[i] <= 'z')) ||
- ((main_str[i] >= 'A' && main_str[i] <= 'Z') && (comp_str[i] >= 'A' && comp_str[i] <= 'Z')))
- {
- //cout << main_str[i] << ' ' << comp_str[i] << endl;
- flag = false;
- break;
- }
- }
- if(flag) cout << "Wrong password. Please, check your caps lock key." << endl;
- else cout << "Wrong password." << endl;
- }
- }
- else
- {
- string temp;
- int k = 0;
- // string dummy1 = main_str, dummy2 = comp_str;
- // transform(dummy1.begin(),dummy1.end(),dummy1.begin(),::tolower);
- // transform(dummy2.begin(),dummy2.end(),dummy2.begin(),::tolower);
- //
- // if(dummy1 != dummy2) cout << "Wrong password." << endl;
- // else
- //{
- for(int i = 0; i < main_len; i++)
- {
- if(main_str[i] != '0' && main_str[i] != '1'
- && main_str[i] != '2' && main_str[i] != '3'
- && main_str[i] != '4' && main_str[i] != '5'
- && main_str[i] != '6' && main_str[i] != '7'
- && main_str[i] != '8' && main_str[i] != '9'
- )
- {
- temp += main_str[i];
- //cout << temp[k-1];
- }
- }
- int temp_len = temp.size();
- //temp[k] = '\0';
- //string temp2 = temp;
- //cout << comp_str << '~' << temp << endl;
- if(comp_str == temp) cout << "Wrong password. Please, check your num lock key." << endl;
- else if(temp_len == comp_len)
- {
- bool flag = true;
- for(int i = 0; i < temp_len; i++)
- {
- if((tolower(temp[i]) != tolower(comp_str[i])) ||
- ((temp[i] >= 'a' && temp[i] <= 'z') && (comp_str[i] >= 'a' && comp_str[i] <= 'z')) ||
- ((temp[i] >= 'A' && temp[i] <= 'Z') && (comp_str[i] >= 'A' && comp_str[i] <= 'Z'))
- )
- {
- flag = false;
- break;
- }
- }
- if(flag) cout << "Wrong password. Please, check your caps lock and num lock keys." << endl;
- else cout << "Wrong password." << endl;
- }
- else cout << "Wrong password." << endl;
- //}
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment