35 lines
723 B
C#
35 lines
723 B
C#
namespace Iteration;
|
|
|
|
public class Recursion
|
|
{
|
|
public static bool IsAlphanum(string s, int i)
|
|
{
|
|
if (i >= s.Length)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= '0' && s[i] <= '9'))
|
|
{
|
|
return IsAlphanum(s, i + 1);
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static string ReverseStr(string source, int lenght)
|
|
{
|
|
if (lenght == 0)
|
|
{
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
return source[lenght - 1] + ReverseStr(source, lenght - 1);
|
|
}
|
|
}
|
|
} |