//换硬币
#include<stdio.h>
int main(int argc,char const *argv[])
{
int money;
int q;
printf("请输入金额(分):");
scanf("%d",&money);
int one,two,five;
double m=1.0*money/100;
for(five=1;five<=money/5;five++)
for(two=1;two<=money/2;two++)
for(one=1;one<=money/1;one++)
if(5*five+2*two+1*one==money)
{
q=five+two+one;
printf("%.2f元可换成%d枚硬币,分别是%d枚五分,%d枚两分,%d枚一分。\n",m,q,five,two,one);
}
return 0;
}
4-5 换硬币
最新推荐文章于 2021-05-24 21:39:38 发布