This commit is contained in:
35
Iteration/Recursion.cs
Normal file
35
Iteration/Recursion.cs
Normal file
@ -0,0 +1,35 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user