/**************************************************
* Greedy.c
*
* CS50x pset1
* Daniel Riley
*
* A program that determines the minimum amount of
* coins used for change owed
*
*
**************************************************/
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main (void);
{
float change;
int cents = round (change * 100);
int coins = 0;
do
{
printf("How much change is required? ");
change = GetFloat();
}
while(change < 0);
do
{
cents -= 25;
coins ++;
}
while(cents >= 25);
do
{
cents -= 10;
coins ++;
}
while(cents >= 10);
do
{
cents -= 5;
coins ++;
}
while(cents >= 5);
do
{
cents -= 1;
coins ++;
}
while(cents >= 1);
printf("%dn", coins);
return 0;
}
我在编译时收到错误的预期标识符"(",请帮助。它是第 17 行,在 int main(void) 之后的行。据我所知,我已经正确括起了所有功能。该程序必须要求用户找零,并确定用于零钱的最少硬币数量
不是
int main(void)
后面的行,而是int main (void);
后面的行。换句话说,删除第 16 行中的;
。
int main()
{
}
错过第 16 行的;
删除main()
函数后面的分号。