S.E.M.F.物理C代码
发布时间:2020-12-16 10:35:35 所属栏目:百科 来源:网络整理
导读:需要一些帮助来解决这个程序的一个小问题.我创建了S.E.M.F.在物理学C计算公式一切都很好,但我的B.E.含有a5的配方. 它说错误:标识符“a5”是未定义的,我知道这意味着什么,但如果我输入偶数甚至奇数或奇数奇怪的A Z值,我将如何从选择语句中获取a5. #include i
需要一些帮助来解决这个程序的一个小问题.我创建了S.E.M.F.在物理学C计算公式一切都很好,但我的B.E.含有a5的配方.
它说错误:标识符“a5”是未定义的,我知道这意味着什么,但如果我输入偶数甚至奇数或奇数奇怪的A Z值,我将如何从选择语句中获取a5. #include <iostream> #include <cstdlib> #include <math.h> using namespace std; int main() { int A,Z; // Main body of Semi-Empirical Mass Formula cout <<"Enter the mass number A: "; cin >> A; cout <<"n"; cout <<"Enter the atomic number Z: "; cin >> Z; cout <<"n"; // Constants from formula,units in MeV(millions of electron volts) double a1 = 15.67; double a2 = 17.23; double a3 = 0.75; double a4 = 93.2; if(Z % 2 == 0 && (A - Z) % 2 == 0) double a5 = 12.0; else if(Z % 2 != 0 && (A - Z) % 2 != 0) double a5 = -12.0; else double a5 = 0; // Formula for to compute the binding energy double B =a1 * A - a2 * pow( A,2/3) - a3 * (pow(Z,2) / pow(A,1/3)) - a4 * (pow(A - 2 * Z,2) / A) + (a5 / pow(A,1/2)); // Formula for to compute the binding energy per nucleon double B_E = B / A; return 0; } 解决方法
把定义
double a5 = 0.0; 在a4定义的正下方,并在每个ifs案例中使用它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |