diff options
author | Santo Cariotti <sancn@live.com> | 2017-01-28 19:13:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-28 19:13:36 +0100 |
commit | f94c453302bcfbaafee2af962bec6bdf09770868 (patch) | |
tree | 21e0619c435ce668a18f4cbce071a24556503c3c /palindromo.cc | |
parent | 088f022f45ba8504b6c108d90a64089066b8221c (diff) |
Rename ConsoleApplication1.cpp to palindromo.cc
Diffstat (limited to 'palindromo.cc')
-rw-r--r-- | palindromo.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/palindromo.cc b/palindromo.cc new file mode 100644 index 0000000..1cb19a2 --- /dev/null +++ b/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;
+}
+
|