shizaero

Untitled

Jun 21st, 2023
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. template <typename F>
  9. string BruteForce(F check) {
  10.    string result = "";
  11.    for(char s1 = 'A'; s1 != 'Z'; ++s1){
  12.        for(char s2 = 'A'; s2 != 'Z'; ++s2){
  13.            for(char s3 = 'A'; s3 != 'Z'; ++s3){
  14.                for(char s4 = 'A'; s4 != 'Z'; ++s4){
  15.                    for(char s5 = 'A'; s5 != 'Z'; ++s5){
  16.                        result.clear();
  17.                        result += s1;
  18.                        result += s2;
  19.                        result += s3;
  20.                        result += s4;
  21.                        result += s5;
  22.                        if(check(result)) return result;
  23.                     }
  24.                }
  25.            }
  26.        }
  27.    }
  28.     //cout << result << endl;
  29.     return result;
  30. }
  31.  
  32. int main() {
  33.     string pass = "ARTUR"s;
  34.     auto check = [pass](const string& s) {
  35.         return s == pass;
  36.     };
  37.     cout << BruteForce(check) << endl;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment