From 05f03ef521fb1e96d7e27374887921560c84593a Mon Sep 17 00:00:00 2001 From: Paloudeh Lover <80192196+TheyCallMeEzraieel@users.noreply.github.com> Date: Fri, 17 May 2024 15:16:17 +0330 Subject: [PATCH] Create solve-Ezraieel.cpp 51NK1N6 1N 0C34N Using stringstream to split words --- strings/tfcctf2023-MAYDAY/solve-Ezraieel.cpp | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 strings/tfcctf2023-MAYDAY/solve-Ezraieel.cpp diff --git a/strings/tfcctf2023-MAYDAY/solve-Ezraieel.cpp b/strings/tfcctf2023-MAYDAY/solve-Ezraieel.cpp new file mode 100644 index 0000000..7bff652 --- /dev/null +++ b/strings/tfcctf2023-MAYDAY/solve-Ezraieel.cpp @@ -0,0 +1,21 @@ +//Author: TheyCallMeEzraieel(Mohammad) +#include +#include +#include +#include + +int main() { + std::string encoded = "Whiskey Hotel Four Tango Dash Alpha Romeo Three Dash Yankee Oscar Uniform Dash Sierra One November Kilo India November Golf Dash Four Bravo Zero Uniform Seven"; //Stores encoded message + std::string decoded; //The decoded message will store into this var + std::map dict{{"One", '1'}, {"Two", '2'}, {"Three", '3'}, {"Four", '4'}, {"Five", '5'}, {"Six", '6'}, {"Seven", '7'}, {"Eight", '8'}, {"Nine", '9'}, {"Zero", '0'}, {"Dash", '-'}}; //A simple dictionary for numbers and dash character + std::istringstream ss(encoded); //Assign a stringstream of the encoded message + std::string word; //Stores each words with shift right operator + while(ss>>word){ + if (dict.find(word) != dict.end()){ //If the word exist in dict + decoded += dict[word]; + } else { //If not + decoded += word[0]; //Stores the first character of the word + } + } + std::cout<