From 36025a787bcea8946922deea6a3b7551d2672c24 Mon Sep 17 00:00:00 2001 From: Charles-Hernandez <71562255+Charles-Hernandez@users.noreply.github.com> Date: Thu, 29 Oct 2020 16:12:26 -0700 Subject: [PATCH] Added Mocking String Program Inspired by spongebob mock, enter a string and get back the same string with jangled capitalization. --- strings/mocking_string.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 strings/mocking_string.cpp diff --git a/strings/mocking_string.cpp b/strings/mocking_string.cpp new file mode 100644 index 0000000..0a4ec93 --- /dev/null +++ b/strings/mocking_string.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() +{ + int c = 0; + char input[101]; + cout << "Enter string to be mocked: "; + cin.getline(input, 101); + + for (int i = 0; input[i] != '\0'; ++i) + { + c += (int) input[i]; + if (input[i] == ' '){} + else if (c % 2 == 0) + input[i] = input[i] ^= 32; //flip character case + } + + cout << "Your mocking string is: " << input; + return 0; +}