标签:interview
int ways(int sum, int n, int cent) // cent is maxCent allow to use. { if (sum == n) return 1; // this way is good. if (sum > n) return 0; // this way is bad. int ways; // sum < n if (cent >= 25) ways += ways(sum + 25, n , 25); if (cent >= 10) ways += ways(sum + 10, n , 10); if (cent >= 5) ways += ways(sum + 5, n, 5); if (cent >= 1) ways += ways(sum + 1, n, 1); return ways; }
标签:interview
原文地址:http://7371901.blog.51cto.com/7361901/1589692