Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2016
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. function OnStart()
  4. {
  5.  
  6.     lay = app.CreateLayout( "linear", "VCenter,FillXY" );  
  7.     var text =  app.CreateText("Result:");
  8.     lay.AddChild( text );
  9.     var result = 0;
  10.     var count = +prompt("Введите кол-во m");
  11. if(count== 1){
  12.     var m = +prompt("Введите m");
  13.     }
  14.     var n = +prompt("Введите n");
  15.     var p = +prompt("Введите p");
  16.     var q = 1-p;
  17.     var a = n*p;
  18.    
  19.     function fact(a)
  20. {
  21. var temp = 1;
  22. for(var i = 1;i<a+1;i++){
  23. temp*=i;}
  24. return temp;
  25.    
  26. }
  27. function soc(m,n)
  28. {
  29.     var result  = fact(n)/(fact(m)*fact(n-m));
  30.  return result;
  31. }
  32.  
  33. function zebra(n,m,p,q)
  34. {
  35. var result = soc(m,n)*Math.pow(p,m)*Math.pow(q,n-m);
  36. return result;
  37. }
  38. function cat(n,m,p,a){
  39.     var result = (Math.pow(a,m)*Math.pow(Math.E,-a))/fact(m);
  40.     return result;
  41.     }
  42. function dog(n,m,p,q){
  43.     var result;
  44.     var x= (m-n*p)/Math.sqrt(n*p*q);
  45.     var f=(1/(Math.sqrt(2*Math.PI)))*Math.pow(Math.E,-(Math.pow(x,2)/2));
  46.     result = (1/(Math.sqrt(n*p*q)))*f;
  47.     return result;}
  48. if(n<20 && count==1 ){
  49. var result = zebra(n,m,p,q)}
  50. if(n<20 && count>1){
  51.  
  52. for(var  i = 0;i<count;i++){
  53. m = +prompt("Введите m" + +(i+1));
  54. result+=zebra(n,m,p,q)}}
  55. if(n>=20 && count==1){
  56.     result=cat(n,m,p,a);
  57.     }
  58. if(n>=20 && count>1){
  59.     for(var i=0;i<count;i++){
  60.         m=+prompt("Введите m"+ +(i+1));
  61.         result+=cat(n,m,p,a);
  62.         }
  63.     }
  64. if(n>=20 && m>=20){
  65.     result=dog(n,m,p,q);}
  66. text.SetText( text.GetText()+" "+ result);
  67.  
  68.  
  69.    
  70.     app.AddLayout( lay );
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement