class Program
{
static void Main(string[] args)
{
string testStr = "sdfadfdsfadfdsfsdf";
int length = testStr.Length;
while (length > )
{ getPalindrome(testStr.Substring(, length - ), testStr.Substring(length - ), new List<string>()); --length;
} Console.ReadKey();
} /// <summary>
///
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
static void getPalindrome(string subLeft, string subRight, List<string> leftPalindromeStr)
{ int length = subRight.Length;
List<string> palindromeStrs = leftPalindromeStr; if (isPalindrome(subLeft) == true)
{
palindromeStrs.Add(subLeft);
if (isPalindrome(subRight))
{
Console.WriteLine("{0},{1}", String.Join(",", palindromeStrs), subRight);
} while (length > )
{
List<string> ss = new List<string>();
ss.AddRange(palindromeStrs);
getPalindrome(subRight.Substring(, length - ), subRight.Substring(length - ), ss);
length--;
}
}
} static bool isPalindrome(string str)
{
int length = str.Length;
int half = length / ; for (int i = ; i < half; i++)
{
if (str[i] != str[length - i - ])
{
return false;
}
} return true;
}
}

C#实现:给定任意要给字符串,输出所有可能的回文的子字符串集合。的更多相关文章

  1. cf#516C. Oh Those Palindromes(最多回文子串的字符串排列方式,字典序)

    http://codeforces.com/contest/1064/problem/C 题意:给出一个字符串,要求重新排列这个字符串,是他的回文子串数量最多并输出这个字符串. 题解:字典序排列的字符 ...

  2. 【Python】回文palindrome——利用字符串反转

    回文 palindrome Python 字符串反转string[::-1] Slice notation "[a : b : c]" means "count in i ...

  3. python经典算法题:求字符串中最长的回文子串

    题目 给定一个字符串 s,找到 s 中最长的回文子串.你可以假设 s 的最大长度为 1000. 示例 1: 输入: "babad" 输出: "bab" 注意: ...

  4. Longest Palindromic Substring - 字符串中最长的回文字段

    需求:Given a string S, find the longest palindromic substring in S. You may assume that the maximum le ...

  5. 九度OJ 1252:回文子串 (字符串处理、DP)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:387 解决:224 题目描述: 输入一个字符串,输出该字符串中对称的子字符串的最大长度. 比如输入字符串"google" ...

  6. 第5题 查找字符串中的最长回文字符串---Manacher算法

    转载:https://www.felix021.com/blog/read.php?2040 首先用一个非常巧妙的方式,将所有可能的奇数/偶数长度的回文子串都转换成了奇数长度:在每个字符的两边都插入一 ...

  7. c++ 获取字符串中最长的回文子串

    #include <vector> #include <iostream> #include <string> using namespace std; strin ...

  8. 647. Palindromic Substrings 互文的子字符串

    [抄题]: Given a string, your task is to count how many palindromic substrings in this string. The subs ...

  9. C语音输出前100个回文素数,每行10个,适当对齐

    #include<stdio.h> #include<math.h> int ss(long n) { ); ) ; ;i<=sqrt(n);i++) ); ; } lo ...

随机推荐

  1. innodb buffer pool小解

    INNODB维护了一个缓存数据和索引信息到内存的存储区叫做buffer pool,他会将最近访问的数据缓存到缓冲区.通过配置各个buffer pool的参数,我们可以显著提高MySQL的性能. INN ...

  2. 使用CSS完美实现垂直居中的方法

    使用XHTML+CSS来实现元素的垂直居中一直是前端开发中的一个比较复杂且棘手的问题,作为网页设计师或前端开发工程师,这个垂直居中问题也是必须掌握的技巧之一,一些互联网公司面试题中也会出现这类题目.今 ...

  3. UVa 488 - Triangle Wave

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...

  4. css 取消默认的padding

    ;;} --透明 兼容写法 filter:alpha(opacity=90);-moz-opacity:0.9; -khtml-opacity: 0.9;opacity: 0.9;

  5. 在 node.js 的 express web 框架中自动注册路由

    该方法主要是动态注册自己写的 router . 注册器 router 文件名为 loader.js  . var express = require('express'); var fs = requ ...

  6. (转)UIWebView全部API学习

    网上找的收藏一下 http://www.myexception.cn/web/1888974.html 最生僻的API做了下划线以及粗体的标注.百度上查了全是拷贝的同一份代码,而且只有代码没有解释,很 ...

  7. DOM元素querySelectorAll可能让你意外的特性表现

    一.时间紧急,废话少说 本文所在的页面藏匿了下面这些代码: <img id="outside"> <div id="my-id"> &l ...

  8. iTerm2 cheatsheet (from github)

    https://gist.github.com/helger/3070258 Tabs and Windows Function Shortcut Previous Tab ⌘+ Left Arrow ...

  9. Java中public,private,protected,和默认的区别

    Java中public,private,protected,和默认的区别 1.private修饰词,表示成员是私有的,只有自身可以访问: 2.protected,表示受保护权限,体现在继承,即子类可以 ...

  10. AWS Redshift summary

    https://blogs.aws.amazon.com/bigdata/post/Tx31034QG0G3ED1/Top-10-Performance-Tuning-Techniques-for-A ...