110,534
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
foreach (var item in foo("adfkjajaj;jjkjbadfdabcbaajkdj,moiu"))
{
Console.WriteLine(item);
}
}
static IEnumerable<string> foo(string s)
{
for (int i = 0; i < s.Length; i++)
{
for (int j = 2; j <= s.Length - i; j++)
{
if (s.Substring(i, j) == new string(s.Substring(i, j).Reverse().ToArray()))
yield return s.Substring(i, j);
}
}
}
}
}
jaj
jajaj
aja
jaj
j;j
jj
jkj
badfdab
adfda
dfd
abcba
bcb
aa
Press any key to continue . . .