此代码的目的是要求进行找零,然后输出可用于提供找零的最小数量的硬币。
不确定我的代码为什么不输出任何内容吗?
#include <cs50.h>
#include <stdio.h>
#include <math.h>
float get_defined_float(string prompt);
int main(void)
{
float f = get_defined_float("Required Change: ");
}
float get_defined_float(string prompt)
{
float n;
do
{
n = get_float("Required Change: ");
}
while (n<=0);
return n;
int input = round(n * 100);
int quarters = input / 25;
int dimes = (input % 25) / 10;
int nickles = (input % 25 % 10) / 5;
int pennies = (input % 5) / 1;
int total = quarters + dimes + nickles + pennies;
printf("%d",total);
}