c语言程序设计:现代方法其中一题
Write a program that asks the user to enter a U.S. dollar amount and then shows how that amount the smallest number of $20,$10,$5,and $1 bills:
#include<stdio.h>
int main()
{
int tmp,t;
printf("Enter a dollar amount:");
scanf("%d",&t);
tmp=t/20;
printf("$20 bills:%d\n",tmp);
t=t-tmp*20;
tmp=t/10;
printf("$10 bills:%d\n",tmp);
t=t-tmp*10;
tmp=t/5;
printf("$5 bills:%d\n",tmp);
t=t-tmp*5;
printf("$1 bills:%d\n",t);
return 0;
}