我更新了我的計算器代碼,並添加了指數函數。然而,當我嘗試獲得方程的答案時,我得到這個錯誤: (lldb) 任何幫助將不勝感激,因爲這是我第一天用C++!是的,就是這樣! 這是我的代碼!在C++上指數的LLDB錯誤
#include <math.h>
#include <iostream>
int int1, int2, answer;
bool bValue(true);
std::string oper;
std::string cont;
using namespace std;
std::string typeOfMath;
int a;
int b;
int answerExponent;
int main(int argc, const char * argv[]){
// Taking user input, the first number of the calculator, the operator, and second number. Addition, Substraction, Multiplication, Division
cout<<"______________________________________________\n";
cout<<"|Welcome to The ExpCalc! Do you want to do |\n";
cout<<"|Exponent Math, or Basic Math(+, -, X, %) |\n";
cout<<"|Type in 'B' for basic Math, and'E' for |\n";
cout<<"|Exponential Math! Enjoy! (C) John L. Carveth|\n";
cout<<"|____________________________________________|\n";
cin>> typeOfMath;
if(typeOfMath == "Basic" ||
typeOfMath == "basic" ||
typeOfMath == "b" ||
typeOfMath =="B")
{
cout << "Hello! Please Type in your first integer!\n";
cin>> int1;
cout<<"Great! Now Enter your Operation: ex. *, /, +, -...\n";
cin>> oper;
cout<<"Now all we need is the last int!\n";
cin>> int2;
if (oper == "+") {
answer = int1 + int2;
}
if (oper == "-") {
answer = int1 - int2;
}if (oper == "*") {
answer = int1 * int2;
}if (oper == "/") {
answer = int1/int2;
}
cout<<answer << "\n";
cout<<"Thanks for Using The ExpCalc!\n";
}else if(typeOfMath == "Exp" ||typeOfMath == "E" ||typeOfMath == "e" ||typeOfMath == "Exponent"){
cout<<"Enter the desired Base. Example: 2^3, where 2 is the base.\n";
cin>> a;
cout<<"Now what is the desired exponent/power of the base? Ex. 2^3 where 3 is the exponent!\n";
cin>>b;
answerExponent = (pow(a,b));
cout<< answerExponent;
} else(cout<<"Wrong String!");
}
請幫忙!我可能會問很多問題,所以請不要生氣!我也在Mac上使用Xcode 4!
你能發佈完整/確切的錯誤消息嗎? – JBentley
完全確切的錯誤信息是(lldb)那就是我給的全部!______________________________________________ |歡迎來到ExpCalc!你想要做什麼|指數數學或基礎數學(+, - ,X,%)| |輸入'B'代表基本數學,'E'代表| |指數數學!請享用! (C)John L. Carveth | | ____________________________________________ | e 輸入所需的基準。例如:2^3,其中2是基數。 現在基地的期望指數/功率是多少?防爆。 2^3其中3是指數! (lldb) –
爲防萬一有些混淆,(lldb)不是錯誤文本,它是調試器的提示符。低級虛擬機DeBugger。類似於GDB。 – Will