Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- template <typename F>
- string BruteForce(F check) {
- string result = "";
- for(char s1 = 'A'; s1 != 'Z'; ++s1){
- for(char s2 = 'A'; s2 != 'Z'; ++s2){
- for(char s3 = 'A'; s3 != 'Z'; ++s3){
- for(char s4 = 'A'; s4 != 'Z'; ++s4){
- for(char s5 = 'A'; s5 != 'Z'; ++s5){
- result.clear();
- result += s1;
- result += s2;
- result += s3;
- result += s4;
- result += s5;
- if(check(result)) return result;
- }
- }
- }
- }
- }
- //cout << result << endl;
- return result;
- }
- int main() {
- string pass = "ARTUR"s;
- auto check = [pass](const string& s) {
- return s == pass;
- };
- cout << BruteForce(check) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment