From 0963b6f2cc8f191caef88008cf296e0f8f30b918 Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 30 Aug 2024 22:00:39 +0200 Subject: more --- 5p16.cpp | 3 ++- 5p20.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 5p20.cpp diff --git a/5p16.cpp b/5p16.cpp index 27c6bcb..cd152ee 100644 --- a/5p16.cpp +++ b/5p16.cpp @@ -1,5 +1,6 @@ #include #include +#include /* * @@ -40,7 +41,7 @@ void nonidiomatic_for(std::vector &nidf) { } int main (int argc, char *argv[]) { - + if(argc > 2 || argc < 2) { return -1; } std::string argv_s = argv[1]; std::vector iv1; diff --git a/5p20.cpp b/5p20.cpp new file mode 100644 index 0000000..3dbb40f --- /dev/null +++ b/5p20.cpp @@ -0,0 +1,30 @@ +#include + +/* + * + * 5.20 + * + * + */ + +int main () { + + std::string s; + std::string tmp; + bool b = false; + while(std::cin >> s) { + if(tmp == s) { + b = true; + break; + } + tmp = s; + } + + if(b) { + std::cout << tmp << std::endl; + } else { + std::cout << "There were no repeating words" << std::endl; + } + + return 0; +} -- cgit v1.2.3