How to write a program that output the number of different ways of arranging the number so that the displayed numbers add up to a fixed sum inputed byt the used.

For example, suppose the sum is 4. There are 8 different arrangements. It has to be listed in dictionary order.
1 1 1 1
1 1 2
1 2 1
1 3
2 1 1
2 2
3 1
4

It goes like this

cout << "Do your homework yourself" << endl;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.