The code is rough. Look at it.
The code written through two-layer loops is not object-oriented, but the class is used in the data structure.
I have been writing a non-recursive search for an hour.
Code
Class Program
{
Class Node
{
Public Node _ last;
Public int _ num;
Public int _ sum;
Public int _ count;
Public Node (Node last, int num)
{
_ Last = last;
_ Num = num;
_ Sum = last. _ sum + num;
_ Count = last. _ count + 1;
}
Public Node (int min)
{
_ Last = null;
_ Num = min;
_ Sum = 0;
_ Count = 0;
}
}
Static void printsplit (int max, int min, int n, int sum)
{
List <Node> collection = new List <Node> ();
Collection. Add (new Node (min ));
Int I = 0;
While (I <collection. Count)
{
Node current = collection [I];
If (current. _ count = n-1)
{
Console. Write (sum-current. _ sum + "");
While (current. _ last! = Null)
{
Console. Write (current. _ num. ToString () + "");
Current = current. _ last;
}
Console. Write ("\ n ");
I ++;
Continue;
}
For (int j = current. _ num; j <max & current. _ sum + j * (n-current. _ count) <= sum; j ++)
{
Collection. Add (new Node (current, j ));
}
I ++;
}
}
Static void Main (string [] args)
{
Printsplit (5, 1, 3, 5 );
}
}