The possibility of targeted scores can target any of the integers between 0 to 10. Includes 0 and 10. A total of 10 times a total of 89 points. Ask the possibility of score. The analysis will see the problem as a plan. Transform into the following problems. There are 10 locations, and each location can be assigned an integer between 0 to 10, so that the sum of the values in all positions is 11 points. Ask the possibility of arranging. Further simplify the problem: 3 positions, make the sum of the 4-point assignment plan? The hand has 15 kinds of verification criteria.
#include "stdafx.h" #define Number 10 # define score 11int arrange_value [10]; int count = 0; void cal (int position, int value) {if (position == Number) {if (value == score) Count ; Return;} for (int i = 0; i <10; i ) {arrange_value [position] = i; cal (position 1, value i);}} int main (int Argc, char * argv [] ) {CAL (0, 0); Printf ("there is% d solutions / n", count); return 0;}
Get it.