📄 let me count the ways.txt
字号:
#include <stdio.h>
#define N 5
#define M 100
main(){
int coin[N]={1,5,10,25,50};
long table[M]={0};
long cent=0,i=0,j=0;
table[0]=1;
for(i=0;i<N;i++){
for(j=coin[i];j<M;j++)
table[j]+=table[j-coin[i]];
}
while(scanf("%ld",¢)==1){
if(table[cent] == 1)
printf("There is only 1 way to produce %ld cents change.\n",cent);
else
printf("There are %ld ways to produce %ld cents change.\n",table[cent],cent);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -