From 013c05f2dd4af5510b97c834887277c380256ed3 Mon Sep 17 00:00:00 2001 From: datalore Date: Wed, 25 Oct 2023 12:29:28 +0200 Subject: [PATCH] Added exceptions for whitespace --- brute.cc | 5 +++++ shift.cc | 5 +++++ vigenere.cc | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/brute.cc b/brute.cc index 6785227..f663e2a 100644 --- a/brute.cc +++ b/brute.cc @@ -5,6 +5,11 @@ void shift(char* text, int key) std::cout << key << ": "; for(int i = 0; text[i] != 0; ++i) { + if(text[i] == ' ') + { + std::cout << ' '; + continue; + } char c = std::tolower(text[i])-key; if(c < 'a') c+=26; if(c > 'z') c-=26; diff --git a/shift.cc b/shift.cc index d7e2ee7..c4694c8 100644 --- a/shift.cc +++ b/shift.cc @@ -15,6 +15,11 @@ int main(int argc, char** argv) for(int i = 0; text[i] != 0; ++i) { + if(text[i] == ' ') + { + std::cout << ' '; + continue; + } char c = std::tolower(text[i])+key; if(c < 'a') c+=26; if(c > 'z') c-=26; diff --git a/vigenere.cc b/vigenere.cc index 9bdc885..c726269 100644 --- a/vigenere.cc +++ b/vigenere.cc @@ -20,6 +20,11 @@ int main(int argc, char** argv) int ki = 0; for(int pi = 0; text[pi] != 0; ++pi) { + if(text[i] == ' ') + { + std::cout << ' '; + continue; + } char c = std::tolower(text[pi]) + keyvalue(key[ki]); if(c < 'a') c+=26; if(c > 'z') c-=26;