将数学方程转换为C++代码

mar*_*ker -2 c++

我在C++ Intro中做了一个功课.其中一个说将以下数学方程式转换为C++代码:

x = 10?/(a+b) sin3C+ 3(ln a)(tan C)
Run Code Online (Sandbox Code Playgroud)

其中a,b和C是用户输入的,C是度.

我自己尝试过并最终得到了这个:

float x,y,z,a,b,C;

cout<< "Input the a-value: ";
cin>> a;

cout<< "\nInput the b-value: ";
cin>> b;

cout<< "\nInput the C-value: ";
cin>> C;
C = C*3.1416/180;

x = (10*3.1416/a+b)*pow(sin(C),3)+3*log(a)*tan(C);
cout<< "\n The value of x is " << x;
Run Code Online (Sandbox Code Playgroud)

我试过a = 5,b = 10,C = 15,x的结果是1.57606.我在科学计算器中尝试过,x变为1.33005.我的代码中可能出现什么问题?谢谢!

如果我的帖子结构有任何问题,我很抱歉,因为这是我第一次在这里发帖,英语不是我的母语

joh*_*ohn 5

(10*3.1416/a+b)
Run Code Online (Sandbox Code Playgroud)

你的意思是和10π/(a + b)不一样

(10*3.1416/(a+b))
Run Code Online (Sandbox Code Playgroud)