Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OnStart()
- {
- lay = app.CreateLayout( "linear", "VCenter,FillXY" );
- var text = app.CreateText("Result:");
- lay.AddChild( text );
- var result = 0;
- var count = +prompt("Введите кол-во m");
- if(count== 1){
- var m = +prompt("Введите m");
- }
- var n = +prompt("Введите n");
- var p = +prompt("Введите p");
- var q = 1-p;
- var a = n*p;
- function fact(a)
- {
- var temp = 1;
- for(var i = 1;i<a+1;i++){
- temp*=i;}
- return temp;
- }
- function soc(m,n)
- {
- var result = fact(n)/(fact(m)*fact(n-m));
- return result;
- }
- function zebra(n,m,p,q)
- {
- var result = soc(m,n)*Math.pow(p,m)*Math.pow(q,n-m);
- return result;
- }
- function cat(n,m,p,a){
- var result = (Math.pow(a,m)*Math.pow(Math.E,-a))/fact(m);
- return result;
- }
- function dog(n,m,p,q){
- var result;
- var x= (m-n*p)/Math.sqrt(n*p*q);
- var f=(1/(Math.sqrt(2*Math.PI)))*Math.pow(Math.E,-(Math.pow(x,2)/2));
- result = (1/(Math.sqrt(n*p*q)))*f;
- return result;}
- if(n<20 && count==1 ){
- var result = zebra(n,m,p,q)}
- if(n<20 && count>1){
- for(var i = 0;i<count;i++){
- m = +prompt("Введите m" + +(i+1));
- result+=zebra(n,m,p,q)}}
- if(n>=20 && count==1){
- result=cat(n,m,p,a);
- }
- if(n>=20 && count>1){
- for(var i=0;i<count;i++){
- m=+prompt("Введите m"+ +(i+1));
- result+=cat(n,m,p,a);
- }
- }
- if(n>=20 && m>=20){
- result=dog(n,m,p,q);}
- text.SetText( text.GetText()+" "+ result);
- app.AddLayout( lay );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement