我正在处理一个小问题,并花了好几个小时试图弄清楚我做错了什么。使用Dev ++编译器,它有时会有一些神秘的错误信息。关于函数和错误检查的新手C++问题
我试图让体积计算功能,并得到它的工作,但我有2个小尼特。我解决这个问题后,将工作在错误检查。
随着函数的增加,出于某种原因现在使用dev ++,程序不会暂停(按任意键继续)。
卷是空白而不是数字。
感谢 PC
// The purpose of this program is to determine the Volume of a
// square-based pyramid after the user inputs the Area and
// the Height.
#include <iostream>
#include <iomanip>
using namespace std;
double calcvolume(double a, double h)
{
double volume;
volume = (a * h)/3;
return (volume);
}
int main()
{
double area, height, volume; // declare variables
cout << "Please enter the Area of the Square-based pyramid:"; // requests users input
cin >> area; // assigns user input to area
cout << "Please enter the Height of the Square-based pyramid:"; // requests user input
cin >> height;
// assigns user input to height
cout << "Area= " << area << "\n"; // Prints user input for area
cout << "Height= " << height << "\n";
calcvolume(area,height);
cout << "Volume= " << fixed << showpoint << setprecision(2) << volume << "\n"; // Prints resolution to the formula stored in volume
system("pause"); // forces DOS window to pause to allow user to utilize program
return 0;
}
如果您在编写函数进行计算时需要帮助,请发布您已经提出的内容,我们将从此处为您提供帮助。 – luke 2010-01-27 18:59:47
我们希望看到你写的内容无效 - 我们无法修复工作代码。 – 2010-01-27 19:01:13
如果你需要帮助来弄清楚为什么事情不起作用,那么显示什么是有效的,而不是没有用的。 – 2010-01-27 19:01:57