1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 密立根油滴实验科大奥瑞计算代码

密立根油滴实验科大奥瑞计算代码

时间:2024-07-02 03:48:22

相关推荐

密立根油滴实验科大奥瑞计算代码

静态法:

#include <iostream>

#include <cmath>

using namespace std;

int main(){

double q, t, r, u, x, x1, x2,n1,e1,e0=1.602;

double p1 = 981,g = 9.80,l = 2.00e-3,b = 8.23e-3,p = 0.101e6,d = 5.00e-3,n = 1.83e-5;

cout<<"先输入时间,再输入电压:"<<endl;

cin>>t>>u;

r = sqrt(9 * n*l / (2 * p1*g*t));

x1 = ((n*l) / (t*(1 + b / (p*r))));

x2 = x1*x1*x1;

x = sqrt(x2);

q = 18 * 3.14*x*d / (sqrt(2 * p1*g)*u);

n1=q/(1.6e-19);

if(n1-int(n1)>=0.5) n1=int(n1)+1;

else if(n1-int(n1)<0.5||n1-int(n1)>=0) n1=int(n1);

else cout<<"error";

e1=q/n1;

cout<<"油滴所带电量q="<<q<<endl;

cout<<"实验数据所得电荷量e="<<e1<<endl;

cout<<"基本电荷相对误差结果u="<<abs(100*(e1*1e19-e0)/e0)<<"%"<<endl;

system("pause");

return 0;

}

动态法:

#include <iostream>

#include <cmath>

using namespace std;

int main(){

double q, r, u, x ,n1,e1,w,tg,te;

double p1 = 981,g = 9.794,l = 2.00e-3,b = 8.22e-3,P = 0.1013e6,d = 5.00e-3,n = 1.83e-5,c=1.602e-19;

cout<<"先输入下降时间,再输入上升时间,再输入上升时的电压(注意不是平衡电压,是平衡电压的1.5倍):"<<endl;

cin >> tg>>te>>u;

r = sqrt(9 * n*l / (2 * p1*g*tg));

x=sqrt((n*l)/(1+b/(P*r)));

q = ((18*3.14)/sqrt(2*p1*g))*x*x*x*(d/u)*(1/tg+1/te)*sqrt(1/tg);

n1=q/(1.602e-19);

if(n1-int(n1)>=0.5) n1=int(n1)+1;

else if(n1-int(n1)<0.5||n1-int(n1)>=0) n1=int(n1);

else cout<<"error";

e1=q/n1;

w=(e1-c)/c;

if(w<0) w=0-w;

else w=w;

cout<<"油滴带电量q= "<<q<<endl;

cout<<"基本电荷带电量e= "<<e1<<endl;

cout<<"相对误差= "<<w*100<<"%"<<endl;

system("pause");

return 0;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。