blob: 3a0618630acf6bb821c29e3c5b187b0db2471fd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
namespace ALGA {
public class StringReverse {
public static String string_reverse(String s) {
if (s.Length == 0) return s;
return s[s.Length - 1] + string_reverse(s.Substring(0, s.Length - 1));
}
public static bool is_palindrome(String s) {
if (s.Length < 2) return true;
if (s[0] != s[s.Length - 1]) return false;
return is_palindrome(s.Substring(1, s.Length - 2));
}
}
}
|