fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. { float q, t, r, u, x, x1, x2,n1,e1,w,tg,te;
  6. float 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;
  7. cout<<"先输入下降时间,再输入上升时间,再输入上升时的电压:"<<endl;
  8. cin >> tg>>te>>u;
  9. r = sqrt(9 * n*l / (2 * p1*g*tg));
  10. x=sqrt((n*l)/(1+b/(P*r)));
  11. q = ((18*3.14)/sqrt(2*p1*g))*x*x*x*(d/u)*(1/tg+1/te)*sqrt(1/tg);
  12. n1=q/(1.602e-19);
  13. if(n1-int(n1)>=0.5)
  14. {
  15. n1=int(n1)+1;
  16. }
  17. else if(n1-int(n1)<0.5||n1-int(n1)>=0)
  18. {
  19. n1=int(n1);
  20. }
  21. else
  22. {
  23. cout<<"error";
  24. }
  25. e1=q/n1;
  26. w=(e1-c)/c;
  27. if(w<0)
  28. w=0-w;
  29. else
  30. w=w;
  31. cout<< "半径r= "<<r <<endl;
  32. cout<<"油滴带电量q= "<< q<<endl;
  33. cout<<"油滴所带基本电荷n= "<<n1<<endl;
  34. cout<<"基本电荷带电量e= "<<e1;
  35. printf("\n");
  36. printf("相对误差= %lf\n",w);
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5432KB
stdin
 
stdout
先输入下降时间,再输入上升时间,再输入上升时的电压:
error半径r=   -nan
油滴带电量q=   -nan
油滴所带基本电荷n=   -nan
基本电荷带电量e=   -nan
相对误差=   -nan