Advertisement
Anik_Akash

login notification c++ implementation

May 14th, 2021 (edited)
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.17 KB | None | 0 0
  1. //             _   _                
  2. //   __ _ _   _| |_| |__   ___  _ __
  3. //  / _` | | | | __| '_ \ / _ \| '__|
  4. // | (_| | |_| | |_| | | | (_) | |  
  5. //  \__,_|\__,_|\__|_| |_|\___/|_|  
  6. //              _ _            _             _    
  7. //   __ _ _ __ (_) | __   __ _| | ____ _ ___| |__  
  8. //  / _` | '_ \| | |/ /  / _` | |/ / _` / __| '_ \
  9. // | (_| | | | | |   <  | (_| |   < (_| \__ \ | | |
  10. //  \__,_|_| |_|_|_|\_\  \__,_|_|\_\__,_|___/_| |_|
  11.  
  12. #include<bits/stdc++.h>
  13. using namespace    std;
  14.  
  15. #define flush        cin.ignore(numeric_limits<streamsize>::max(),'\n')
  16. #define fasterio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  17. #define NL           cout<<endl;
  18. #define pi           acos(-1.0) //3.1415926535897932384626
  19. #define dpoint(x)    fixed<<setprecision(x)
  20. #define debug(x)     cout<<x<<endl;
  21. #define gcd(a,b)     __gcd(a,b);
  22. #define lcm(x,y)     (a * (b / gcd(a, b)));
  23. #define pb           push_back
  24. #define mx          100000005
  25.  
  26. typedef long long int       ll;
  27. typedef double              dl;
  28. typedef unsigned long long  ul;
  29.  
  30. // --------------------------Pre made Functions & Proto Type--------------------------//
  31. template <class T> T digitsum(T n){T sum=0;while(n!=0){sum+=n%10;n/=10;}return sum;}
  32.  
  33. string pass, in, test;
  34.  
  35. bool num_checker()
  36. {
  37.     int pass_digit=0, in_digit=0;
  38.     for(int i=0; i<pass.size(); i++)
  39.     {
  40.         if(isdigit(pass[i]))pass_digit++;
  41.     }
  42.     for(int i=0; i<in.size(); i++)
  43.     {
  44.         if(isdigit(in[i]))in_digit++;
  45.     }
  46.     if(pass_digit>0 && in_digit==0)
  47.     return true;
  48.     else return false;
  49. }
  50. bool caps_checker()
  51. {
  52.      for(int i=0; i<pass.size(); i++)
  53.     {
  54.         if( !isdigit(pass[i]) )test+=pass[i];
  55.     }
  56.      
  57.          for(int i=0; i<test.size(); i++)
  58.         {
  59.             if( (test[i]>='A' && test[i]<='Z') && (in[i]>='a' && in[i]<='b'))
  60.             {
  61.                 char c = toupper(in[i]);
  62.                 if(test[i]  == c )continue;
  63.                 else return false;
  64.             }
  65.             else if( (test[i]>='a' && test[i]<='z') && (in[i]>='A' && in[i]<='Z'))
  66.             {
  67.                 char c = tolower(in[i]);
  68.                 if(test[i]  == c )continue;
  69.                 else return false;
  70.             }
  71.             else if(test[i]==in[i])continue;
  72.             else return false;
  73.         }
  74.  
  75.     return true;
  76. }
  77.  
  78. int main()
  79. {
  80.     #ifdef EXTRA_8
  81.         clock_t tStart = clock();
  82.         freopen("input.txt","r",stdin);
  83.         freopen("out.txt","w",stdout);
  84.     #endif
  85.         int t;
  86.         cin>>t;
  87.         for(int k=1; k<=t; k++)
  88.         {
  89.             cin>>pass>>in;
  90.             cout<<"Case "<<k<<": ";
  91.             if(pass.size() == in.size())
  92.             {
  93.                 bool flg = true;
  94.                 for(int i=0; i<pass.size(); i++)
  95.                 {
  96.                     if(pass[i]==in[i])continue;
  97.                     else {flg = false; break;}
  98.                 }
  99.                 if(flg)cout<<"Login successful."<<endl;
  100.                 else {
  101.                    int x = num_checker(); int y = caps_checker();
  102.                    if(x == 1 && y == 1)cout<<"Wrong password. Please, check your caps lock and num lock keys."<<endl;
  103.                    else if(x==1)cout<<"Wrong password. Please, check your num lock keys."<<endl;
  104.                    else if(y==1)cout<<"Wrong password. Please, check your caps lock keys."<<endl;
  105.                    else cout<<"Wrong password."<<endl;
  106.                 }
  107.             }
  108.             else cout<<"Wrong password."<<endl;
  109.         }
  110.        
  111.     #ifdef EXTRA_8
  112.         fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  113.     #endif
  114.     return 0;
  115. }
  116.  
  117.  
  118.  
  119.  
  120. //  _____            _   _            _                      ___   __
  121. // |  ___|__  _ __  | |_| |__   ___  | |    _____   _____   / _ \ / _|
  122. // | |_ / _ \| '__| | __| '_ \ / _ \ | |   / _ \ \ / / _ \ | | | | |_
  123. // |  _| (_) | |    | |_| | | |  __/ | |__| (_) \ V /  __/ | |_| |  _|
  124. // |_|  \___/|_|     \__|_| |_|\___| |_____\___/ \_/ \___|  \___/|_|                                                                    
  125. //   ____ ____  
  126. //  / ___|  _ \
  127. // | |   | |_) |
  128. // | |___|  __/
  129. //  \____|_|    
  130. //            
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement