我弄不明白为什么我的程序不会打印最终解决方案(totalDough)。输入是8,10,12然后40,100和200:打印解决方案(新的C)
const int DOUGH_PER_SQFT = 0.75;
const int INCHES_PER_FEET = 12;
#define M_PI 3.14159265358979323846
int main(){
// Declare and initialize variables
int smallRIn;
printf("What is the radius of your small pizza, in inches?\n");
scanf("%d", &smallRIn);
int mediumRIn;
printf("What is the radius of your medium pizza, in inches?\n");
scanf("%d", &mediumRIn);
int largeRIn;
printf("What is the radius of your large pizza, in inches?\n");
scanf("%d", &largeRIn);
// Get number of pizzas sold
int smallSold;
printf("How many small pizzas do you expect to sell this week?\n");
scanf("%d", &smallSold);
int mediumSold;
printf("How many medium pizzas do you expect to sell this week?\n");
scanf("%d", &mediumSold);
int largeSold;
printf("How many large pizzas do you expect to sell this week?\n");
scanf("%d", &largeSold);
// Convert radii to feet
double smallRFeet, mediumRFeet, largeRFeet;
smallRFeet = smallRIn/INCHES_PER_FEET;
mediumRFeet = mediumRIn/INCHES_PER_FEET;
largeRFeet = largeRIn/INCHES_PER_FEET;
// Calculate top surface areas of each type of pizza.
double areaSmall, areaMedium, areaLarge;
areaSmall = smallSold*M_PI*pow(smallRFeet,2);
areaMedium = mediumSold*M_PI*pow(mediumRFeet,2);
areaLarge = largeSold*M_PI*pow(largeRFeet,2);
// Print solution
double dough;
dough = areaSmall+areaMedium+areaLarge;
double total_dough;
total_dough = dough * DOUGH_PER_SQFT;
printf("The total amount of dough you need to order this week is", total_dough);
return 0;
}
我在做什么错?
我希望较小的一段代码,不为你工作,你尝试过什么更好的标题和更多,以及它如何失败。 – 2014-09-21 16:43:13