summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-08-29 16:24:16 +0200
committerOskar <[email protected]>2024-08-29 16:24:16 +0200
commite039d589d29ab799c20fe845d5a005dc257f9a44 (patch)
tree6d89c035ee7c059813e0d34a8dc21f500ad27c1f
parent5cff617b2aa2148773256eed1a00607e0189529b (diff)
more
-rw-r--r--5p12.cpp16
-rw-r--r--5p13.cpp8
-rw-r--r--switch-test.cpp25
3 files changed, 47 insertions, 2 deletions
diff --git a/5p12.cpp b/5p12.cpp
index c9c6117..6cf79e8 100644
--- a/5p12.cpp
+++ b/5p12.cpp
@@ -7,6 +7,22 @@
*
*/
+/*
+ The solution for this exercise is pretty ugly i will admit.
+ One other thing to note here is that the exercise can be
+ interpreted in various different ways. Should it count all
+ occurances of fl, ff, fi in one counter? Or should they all
+ have their own counters? I went with the first one but this
+ could just as well be the latter interpretation. I actually
+ thought this would be easy going in to it but i struggled
+ with bugs where i input strings like "fafafafa". Because it
+ would still count because whenever it encounters characters
+ that aren't f, i, l it does not reset the factive variable
+ so i added factive = false; to all the if statement blocks.
+
+ Again, not pretty but it did the job.
+ */
+
int main () {
char Character = 0;
diff --git a/5p13.cpp b/5p13.cpp
index 58d5fbf..503bc03 100644
--- a/5p13.cpp
+++ b/5p13.cpp
@@ -1,12 +1,16 @@
-#include <iostream>
/*
*
- * Description
+ * 5.13
*
*
*/
int main () {
+
+ // (a) there are no breaks, so we add breaks after each case
+ // (b) ix is initialized in case 1 but we try to use it in default, we add brackets and initialize it in default as well, or maybe make the variable global
+ // (c) we can only have one value per case, we would need to add a case for each value so it can fall through
+ // (d) case labels must be integral constant expressions
return 0;
}
diff --git a/switch-test.cpp b/switch-test.cpp
new file mode 100644
index 0000000..1f6171d
--- /dev/null
+++ b/switch-test.cpp
@@ -0,0 +1,25 @@
+#include <iostream>
+
+/*
+ *
+ *
+ *
+ *
+ */
+
+int main () {
+
+ int j = 0;
+ constexpr int ff = 0;
+ constexpr int ff2 = 2;
+ switch(j) {
+ case ff:
+ std::cout << "!!!" << std::endl;
+ break;
+ case ff2:
+
+ break;
+ }
+
+ return 0;
+}