我已经在这段代码上工作了几个小时,但无法弄清楚我做错了什么。 我基本上需要询问这个人想要多少 cookies ,多少杯柠檬水,以及他们有多少钱,然后归还零钱。 我已经查看了该代码 100 多次,它看起来很完美! 有什么想法吗?!
/作业#2/
#include <stdio.h>
#define LEMONADE_PRICE 0.75
#define COOKIE_PRICE 0.50
intmain(){
int numCookies,numLemonades;
float cost,cash,change;
printf("Welcome to Abigail's Lemons&Cookies!\n");
printf("How many cookies would you like?\n");
scanf("%d",&numCookies);
printf("How many cups of lemonades would you like?\n");
scanf("%d",&numLemonades);
cost=(numCookies*COOKIE_PRICE) + (numLemonades*LEMONADE_PRICE);
printf("That will be %.2f.\n",cost);
printf("How much money do you have?\n");
scanf("%f",&cash);
change=cash - cost;
printf("Your change is %.2f. Have a nice day!\n",change);
return 0;
}
最佳答案
你有一个错字。这:
intmain(){
应该是这样的:
int main(){
关于C 函数中出现错误 `main' : undefined reference to `WinMain' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32534513/