三角猫 很不仗义的说
自己有问题了 自己解决了 也不吱一声 就把自己的帖子删除了
不仗义
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace splitString
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入您要分解的字符串");
string m_string = Console.ReadLine();
ArrayList[] getString=DealString(m_string);
int numCount = 0;
if (getString != null)
{
foreach (ArrayList c in getString)
{
if (c != null)
{
numCount++;
Console.WriteLine("第{0}种分类情况为", numCount);
for (int i = 0; i < c.Count; i++) {
Console.WriteLine("({0}/{1}){2}", i+1, c.Count, c[i].ToString());
}
}
}
}
Console.Read();
}
private static ArrayList[] DealString(string m_string)
{
int m_length = m_string.Length;
int tempa;
int number;
ArrayList[] all=new ArrayList[m_length];
number = 0;
for (int i = 1; i <= m_length; i++) {
//分成的temp段的新加字段的长度
tempa = 0;
for (int j = 1; j <= i; j++) {
tempa += j.ToString().Length;
}
tempa += i * 2;
if ((tempa + m_length) % i == 0)
{
all[number] = new ArrayList();
all[number] = DealString(m_string, i);
number++;
}
}
return all;
}
private static ArrayList DealString(string m_string, int N)
{
int m_length = m_string.Length;
if (m_length < N) {
Console.WriteLine("貌似不能分成这么多段");
return null;
}
ArrayList al = new ArrayList();
int temp=m_length/N;
for (int i = 0; i < m_length-temp; i+=temp) {
al.Add(m_string.Substring(i,temp));
}
al.Add(m_string.Substring(m_length-temp));
return al;
}
}
}
本来想到 三脚猫的 那个问题是 分解质因数 就可以解决的 后来一想 不是这样的
只好用穷举法解决
不仗义
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace splitString
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入您要分解的字符串");
string m_string = Console.ReadLine();
ArrayList[] getString=DealString(m_string);
int numCount = 0;
if (getString != null)
{
foreach (ArrayList c in getString)
{
if (c != null)
{
numCount++;
Console.WriteLine("第{0}种分类情况为", numCount);
for (int i = 0; i < c.Count; i++) {
Console.WriteLine("({0}/{1}){2}", i+1, c.Count, c[i].ToString());
}
}
}
}
Console.Read();
}
private static ArrayList[] DealString(string m_string)
{
int m_length = m_string.Length;
int tempa;
int number;
ArrayList[] all=new ArrayList[m_length];
number = 0;
for (int i = 1; i <= m_length; i++) {
//分成的temp段的新加字段的长度
tempa = 0;
for (int j = 1; j <= i; j++) {
tempa += j.ToString().Length;
}
tempa += i * 2;
if ((tempa + m_length) % i == 0)
{
all[number] = new ArrayList();
all[number] = DealString(m_string, i);
number++;
}
}
return all;
}
private static ArrayList DealString(string m_string, int N)
{
int m_length = m_string.Length;
if (m_length < N) {
Console.WriteLine("貌似不能分成这么多段");
return null;
}
ArrayList al = new ArrayList();
int temp=m_length/N;
for (int i = 0; i < m_length-temp; i+=temp) {
al.Add(m_string.Substring(i,temp));
}
al.Add(m_string.Substring(m_length-temp));
return al;
}
}
}
本来想到 三脚猫的 那个问题是 分解质因数 就可以解决的 后来一想 不是这样的
只好用穷举法解决