整数划分(计数)

#include <cstdlib> #include <iostream> using namespace std; int getCount(int value, int max) { if(value < 1 || max < 1) return 0; if(value == 1 || max == 1) return 1; if(value <= max) return 1 + getCount(value, value - 1); else return getCount(value, max - 1) + getCount(value - max, max); } int main(int argc, char *argv[]) { int value; cout << "please input a value: "; cin >> value; int count = getCount(value, value); cout << count << endl; system("PAUSE"); return EXIT_SUCCESS; }  

你可能感兴趣的:(System,input,include)