我正在尝试创建一个程序来计算我的 Kerbal Space Program 游戏的 Delta-V,而 C++(在 Eclipse IDE 中运行)不允许使用 log() 除非我正在尝试调用一个函数。非常感谢您的帮助!你真好。`
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout << "Hello. Welcome to the Kerbal Space Program Delta V Calculator. \n";
cout << " \n";
cout << "Note that each stage must use the same engine for this calculator.";
cout << "\n";
cout << "\nHow many stages make up your rocket? :";
int stageNumber;
cin >> stageNumber;
//cout << "Your rocket has " << stageNumber << " stages.\n";
cout << "\n\nStart from the bottom stage, please. ";
//ACTUAL DELTA V CALCULATIONS
for(int currentStage = 1; currentStage <= stageNumber; currentStage = currentStage + 1){
cout << "What is the total mass of this stage? :";
int totalMass;
cin >> totalMass;
cout << "What is the fuel mass of this stage? :";
int fuelMass;
cin >> fuelMass;
cout << "\n";
int dryMass;
dryMass = totalMass - fuelMass;
cout << "Your dry mass is" << dryMass << "\n";
cout << "\n";
cout << "Give the specific impulse of this stage's engine. \n";
int iSP;
cin >> iSP;
cout << "Here is the Delta V of your rocket.\n";
int deltaMass;
deltaMass = totalMass/dryMass;
int deltaV;
deltaV = iSP * log(deltaMass);
cout << deltaMass
exit(0);
}
}
`
最佳答案
log()
是 C 标准库中的一个函数,它取一个数的自然对数。该名称实际上是保留的——选择其他名称。
关于c++ - KSP DELTA V 查找器 : Why does C++ assume that log( ) is a function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25496046/