From 1d105b91b9678ffaa8eddea2218ed1789f5be27c Mon Sep 17 00:00:00 2001 From: Oskar Date: Sat, 3 Aug 2024 22:51:15 +0200 Subject: more assignments --- 3p4.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 3p4.cpp (limited to '3p4.cpp') diff --git a/3p4.cpp b/3p4.cpp new file mode 100644 index 0000000..2545618 --- /dev/null +++ b/3p4.cpp @@ -0,0 +1,42 @@ +#include +#include "sales_data.hpp" +#include "sales_item.hpp" + +/* + * + * 3.4 + * + * + */ + +using std::string; +using std::cout; +using std::cin; +using std::cerr; +using std::clog; +using std::endl; +int main () { + + string word1; + string word2; + cin >> word1 >> word2; + if(word1 == word2) { + cout << word1 << " and " << word2 << " are equal! " << endl; + } else if (word1 > word2) { + cout << word1 << " is larger than " << word2 << endl; + } else if (word2 > word1) { + cout << word2 << " is larger than " << word1 << endl; + } + + string::size_type w1 = word1.size(); + string::size_type w2 = word2.size(); + if(w1 == w2) { + cout << word1 << " and " << word2 << " have the same length" << endl; + } else if (w1 > w2) { + cout << word1 << " has a longer length than " << word2 << endl; + } else if (w2 > w1) { + cout << word2 << " has a longer length than " << word1 << endl; + } + + return 0; +} -- cgit v1.2.3