零钱兑换,1,2,5
一张百元大钞,兑换成,1元,2元,和5元的纸币,共有几种方法 # include <stdio.h> int main ( ) { int n ; int cnt = 0 ; scanf ( "%d" , & n ) ; for ( int i = 0 ; i <= n / 5 ; i ++ ) { /*用次数少的循环套次数多的循环*/ for ( int j = 0 ; j <= n / 2 ; j ++ ) { for ( int k = 0 ; k <= n ; k ++ ) { if ( 5 * i + 2 * j + k == n ) cnt ++ ; } } } printf ( "%d" , cnt ) ; return 0 ; } 来源: CSDN 作者: lizyviking_ 链接: https://blog.csdn.net/lizyviking_/article/details/104397595