满意答案
zjhydtsq
2013.09.11
采纳率:54% 等级:12
已帮助:25580人
#include
void main(){
int n;
printf("输入要找的硬币总数:");
scanf("%d",&n);
int five_cent = 0;//5角
five_cent = n/50;
n -= five_cent * 50;
int one_cent = 0;//1角
one_cent = n/10;
n -= one_cent * 10;
int five_penny = 0;//5分
five_penny = n/5;
n -= five_penny * 5;
int two_penny = 0;//2分
two_penny = n/2;
n -= two_penny * 2;
int one_penny = 0;//1分
one_penny = n;
printf("5角:%d\n",five_cent);
printf("1角:%d\n",one_cent);
printf("5分:%d\n",five_penny);
printf("2分:%d\n",two_penny);
printf("1分:%d\n",one_penny);
}
02分享举报