Question: 1. Brute Force Code Cracking When we use brute force methods to crack a cipher, we often generate all possible decryption keys and use them
1. Brute Force Code Cracking
When we use brute force methods to crack a cipher, we often generate all possible decryption keys and use them all. The output from an incorrect decryption key is just some gibberish, but the real key will produce a string that looks like an English sentence.
Write a function that takes in a string and returns true if the string looks like a sentence. That is to say it contains words, separated by spaces
Function signature:
bool valid(std::string s)
____________________________________my code till now ______________________
#include
using namespace std; bool valid(std::string s) { for (int i = 0; i < s.size(); ++i) if (s[i] == ' '){ return true; } return false; } int main() { string s = "This is a sentence" ; cout << valid(s); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
