From 38c566df81011415c2ab10b7deb6e1a11b691d71 Mon Sep 17 00:00:00 2001 From: OfekSusan <97606008+ofekSushan@users.noreply.github.com> Date: Tue, 12 Dec 2023 04:35:41 +0200 Subject: [PATCH] Create New C++ file (#202) --- C++/ofekSushan.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 C++/ofekSushan.cpp diff --git a/C++/ofekSushan.cpp b/C++/ofekSushan.cpp new file mode 100644 index 0000000..6721b81 --- /dev/null +++ b/C++/ofekSushan.cpp @@ -0,0 +1,28 @@ +#include +#include +using namespace std; + +int main() +{ + bool replace = false; + string coffee = "coffee"; + cout << coffee << endl; + for (int index = 0; index < coffee.size() - 1; index++) + { + if (!replace && coffee[index] == 'f') + { + coffee[index] = 'd'; + + replace = true; + } + else if (coffee[index] == 'f' || coffee[index] == 'e') + { + coffee.erase(index, 1); + index--; + } + } + + cout << coffee << endl; + + return 0; +}