aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk5/lab4/mysteryBox.cpp
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-03-27 12:33:52 -0500
committerRossTheRoss <msattr@gmail.com>2019-03-27 12:33:52 -0500
commit42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5 (patch)
treefb507cfea88fd54b2078f60f3f5935c62685d502 /ee1301/wk5/lab4/mysteryBox.cpp
parentUpload bad thing (diff)
downloadhomework-42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5.tar
homework-42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5.tar.gz
homework-42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5.tar.bz2
homework-42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5.tar.lz
homework-42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5.tar.xz
homework-42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5.tar.zst
homework-42cd39b0f8ddda09c3d4bb590f61450bf6c2b0f5.zip
Post-Spring Lab
Diffstat (limited to 'ee1301/wk5/lab4/mysteryBox.cpp')
-rw-r--r--ee1301/wk5/lab4/mysteryBox.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/ee1301/wk5/lab4/mysteryBox.cpp b/ee1301/wk5/lab4/mysteryBox.cpp
new file mode 100644
index 0000000..4737fdd
--- /dev/null
+++ b/ee1301/wk5/lab4/mysteryBox.cpp
@@ -0,0 +1,18 @@
+#include <iostream>
+#include <string>
+using namespace std;
+
+bool mystery(string fstr);
+int main () {
+ string e = "Sargent Pepper's Lonely Hearts Club Band";
+ cout << mystery(e) << endl;
+}
+
+bool mystery(string fstr) {
+ string rstr; // a string is like an array of chars, e.g., char[]
+ for(int i=fstr.length()-1; i>=0 ;i--){
+ rstr += fstr[i]; // fstr[i] gets the char at index i
+ }
+ cout << fstr << endl << rstr << endl;
+ return rstr == fstr;
+}