【发布时间】:2021-02-25 13:49:17
【问题描述】:
我的代码需要帮助。我的代码是 C 源代码格式,但它不能在 Dev C++ 软件上运行。我和我的队友检查了几次,我的代码没有错误,但它就是无法运行。有人,请帮助我。谢谢。
#include<stdio.h>
#include<stdlib.h>
#define TAX 0.08
void getInput(struct order myOrder[], int order);
void processOrder(struct order myOrder[], int order);
struct order
{
char productID[6];
float unitPrice, grossTotal, netTotal, serviceTax;
int qtyOrdered;
};
main()
{
struct order myOrder[50];
int order;
printf("ORDER PROCESSING\n");
printf("=================\n");
printf("How many orders today ? ");
scanf("%d", &order);
getInput(myOrder, order);
processOrder(myOrder, order);
system("PAUSE");
}
void getInput(struct order myOrder[], int order)
{
for (int i = 0;i < order;i++)
{
printf("Enter productID :");
scanf("%s", &myOrder[i].productID);
printf("Enter unit price : RM ");
scanf("%f", &myOrder[i].unitPrice);
printf("Enter quantity ordered : ");
scanf("%d", &myOrder[i].qtyOrdered);
printf("\n");
}
}
void processOrder(struct order myOrder[], int order)
{
float sum = 0.0;
for (int i = 0;i < order;i++)
{
printf("Order : %s\n", myOrder[i].productID);
printf("Unit Price : RM %.2f\n", myOrder[i].unitPrice);
printf("Qty Ordered : %d\n", myOrder[i].qtyOrdered);
myOrder[i].grossTotal = myOrder[i].unitPrice * myOrder[i].qtyOrdered;
printf("Gross Revenue : RM %.2f\n", myOrder[i].grossTotal);
myOrder[i].serviceTax = myOrder[i].grossTotal * TAX;
printf("Service Tax : RM %.2f\n", myOrder[i].serviceTax);
myOrder[i].netTotal = myOrder[i].grossTotal - myOrder[i].serviceTax;
printf(": : Net Revenue : RM%.2f\n\n", myOrder[i].netTotal);
sum += myOrder[i].netTotal;
}
printf("* TOTAL INCOME EARN :: RM%.2f", sum);
}
【问题讨论】:
-
“就是不能跑”是什么意思?
-
C程序从上到下编译执行。以您编写代码的方式。所以你不能引用你还没有写或打算写得更远的东西。