summaryrefslogtreecommitdiff
path: root/cpp/palindromo.cc
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-04-26 16:37:39 +0200
committerSanto Cariotti <sancn@live.com>2017-04-26 16:37:39 +0200
commit483d63fa7249ad8d6020680c48c3cf6df35010b3 (patch)
tree2f8649e3ae6b42ace5011246285c9c450f004222 /cpp/palindromo.cc
parent6c957dc4e01aee6ce9cae3c8342d04b0fd9ca9c4 (diff)
Moved all C++ files into CPP folder
Diffstat (limited to 'cpp/palindromo.cc')
-rw-r--r--cpp/palindromo.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/palindromo.cc b/cpp/palindromo.cc
new file mode 100644
index 0000000..1cb19a2
--- /dev/null
+++ b/cpp/palindromo.cc
@@ -0,0 +1,25 @@
+// ConsoleApplication1.cpp : definisce il punto di ingresso dell'applicazione console.
+//
+#include "stdafx.h"
+#include <iostream>
+
+using namespace std;
+
+bool palindromo(int i, int j, char str[])
+{
+ if (i >= j) return true;
+ else if (str[i] == str[j]) return palindromo(i + 1, j - 1, str);
+ else return false;
+}
+
+int main()
+{
+ char parola[] = "onorarono";
+
+ cout << ( (palindromo(0, sizeof parola - 2, parola) == 1) ? "E' palindromo" : "Non e' palindromo" ) << endl;
+
+ cin.get();
+
+ return 0;
+}
+