Join in with Lao Zhao's small questions

Source: Internet
Author: User

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 );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.