整数划分(计数+划分显示)

#include #include using namespace std; const int MAX = 100; int fac[MAX] = {0}; int sum(int count) { int sum = 0; for(int i=0; i<=count; i++) sum += fac[i]; return sum; } void display(int count, int value) { if(count == 0) cout << value << " + " << "0" << endl; else { for(int i=0; i0; i--) { fac[count] = i; if(value == sum(count)) { display(count, value); count1++; } else if(value < sum(count)) continue; if(count >= value) continue; division(i, count + 1, value); } return count1; } int main(int argc, char *argv[]) { int value; cout << "please input a value: "; cin >>value; cout << "division count is: " << division(value, 0, value) << endl; system("PAUSE"); return EXIT_SUCCESS; }  

你可能感兴趣的:(include,system,input,基本算法)