Robert_JR

5047 - Arbiter Login

Oct 11th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.91 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <cstring>
  4. #include <iostream>
  5. #include <cstdlib>
  6. #include <string>
  7. #include <vector>
  8. #define DEBUGG freopen("f:\\in.txt", "rt", stdin);freopen("f:\\out.txt", "wt, "stdout");
  9. #define SF scanf
  10. #define PF printf
  11. #define TESTCASE int t;scanf("%d", &t);getchar();while(t--)
  12. #define FOR(n) for(int i = 0; i < n; i++)
  13. #define N 100000
  14. using namespace std;
  15.  
  16. int main()
  17. {
  18.     //DEBUGG
  19.     string main_str, comp_str;
  20.     int tc = 1;
  21.  
  22.     int t;
  23.     scanf("%d", &t);
  24.     getchar();
  25.     while(t--)
  26.     {
  27.         cin >> main_str >> comp_str;
  28.         //cout << main_str << ' ' << comp_str << endl;
  29.         PF("Case %d: ", tc++);
  30.  
  31.         int main_len = main_str.size();
  32.         int comp_len = comp_str.size();
  33.  
  34.         if(comp_len > main_len)
  35.         {
  36.             //PF("
  37.             PF("Wrong password.\n");
  38.         }
  39.         else if(main_len == comp_len)
  40.         {
  41.             if(main_str == comp_str) cout << "Login successful." << endl;
  42.             else
  43.             {
  44.                 bool flag = true;
  45.                 for(int i = 0; i < main_len; i++)
  46.                 {
  47.                     if((tolower(main_str[i]) != tolower(comp_str[i])) ||
  48.                             ((main_str[i] >= 'a' && main_str[i] <= 'z') && (comp_str[i] >= 'a' && comp_str[i] <= 'z')) ||
  49.                             ((main_str[i] >= 'A' && main_str[i] <= 'Z') && (comp_str[i] >= 'A' && comp_str[i] <= 'Z')))
  50.                     {
  51.                         //cout << main_str[i] << ' ' << comp_str[i] << endl;
  52.                         flag = false;
  53.                         break;
  54.                     }
  55.                 }
  56.                 if(flag) cout << "Wrong password. Please, check your caps lock key." << endl;
  57.                 else cout << "Wrong password." << endl;
  58.             }
  59.         }
  60.         else
  61.         {
  62.             string temp;
  63.             int k = 0;
  64. //            string dummy1 = main_str, dummy2 = comp_str;
  65. //            transform(dummy1.begin(),dummy1.end(),dummy1.begin(),::tolower);
  66. //            transform(dummy2.begin(),dummy2.end(),dummy2.begin(),::tolower);
  67. //
  68. //            if(dummy1 != dummy2) cout << "Wrong password." << endl;
  69. //            else
  70.             //{
  71.             for(int i = 0; i < main_len; i++)
  72.             {
  73.                 if(main_str[i] != '0' && main_str[i] != '1'
  74.                         && main_str[i] != '2' && main_str[i] != '3'
  75.                         && main_str[i] != '4' && main_str[i] != '5'
  76.                         && main_str[i] != '6' && main_str[i] != '7'
  77.                         && main_str[i] != '8' && main_str[i] != '9'
  78.                   )
  79.                 {
  80.                     temp += main_str[i];
  81.                     //cout << temp[k-1];
  82.                 }
  83.             }
  84.             int temp_len = temp.size();
  85.             //temp[k] = '\0';
  86.             //string temp2 = temp;
  87.             //cout << comp_str << '~' << temp << endl;
  88.  
  89.             if(comp_str == temp) cout << "Wrong password. Please, check your num lock key." << endl;
  90.             else if(temp_len == comp_len)
  91.             {
  92.                 bool flag = true;
  93.                 for(int i = 0; i < temp_len; i++)
  94.                 {
  95.                     if((tolower(temp[i]) != tolower(comp_str[i])) ||
  96.                             ((temp[i] >= 'a' && temp[i] <= 'z') && (comp_str[i] >= 'a' && comp_str[i] <= 'z')) ||
  97.                             ((temp[i] >= 'A' && temp[i] <= 'Z') && (comp_str[i] >= 'A' && comp_str[i] <= 'Z'))
  98.                       )
  99.                     {
  100.                         flag = false;
  101.                         break;
  102.                     }
  103.                 }
  104.                 if(flag) cout << "Wrong password. Please, check your caps lock and num lock keys." << endl;
  105.                 else cout << "Wrong password." << endl;
  106.             }
  107.             else cout << "Wrong password." << endl;
  108.             //}
  109.         }
  110.     }
  111.  
  112.     return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment