返回信息流b=B(s,b)
已知s,求解b的值
等待达人解答[em21]
这是一条镜像帖。来源:北邮人论坛 / matlab / #821同步于 2007/5/12
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Matlab机器人发帖
【求助】erlangB 公式求解问题
dooyingthan
2007/5/12镜像同步1 回复
订阅后,新回复会通过你的通知中心匿名送达。
1 条回复
/* Note:Your choice is C IDE */
#include "stdio.h"
double power(float x,int n)
{
int i;
double y;
y=1;
for(i=1;i<=n;i++)
{
y=y*x;
}
return y;
}
double jiecheng(int n)
{
double y;
int i;
y=1;
if(n==0)
{
return y;
}
else
{
for(i=1;i<=n;i++)
y=y*i;
return y;
}
}
float returnB(int s,float a)
{
int r;
float B;
double tmp,tmp2,tmp1;
tmp=0;
for(r=0;r<=s;r++)
{tmp=power(a,r)/jiecheng(r)+tmp;}
printf("tmp=%f",tmp);
tmp1=jiecheng(s);
printf("tmp1=%f",tmp1);
tmp2=power(a,s)/tmp1;
printf("tmp2=%f",tmp2);
B=tmp2/tmp;
printf("B=%f",B);
/*printf("B=%f",B);*/
return B;
}
float returna()
{
float i,B,t,k,r,tmp;
int s;
tmp=0;
i=0;
printf("B=");
scanf("%f",&B);
printf("s=");
scanf("%d",&s);
while(tmp<B)
{
i++;
tmp=returnB(s,i);
}
r=i-1;tmp=0;
while(tmp<B)
{
r=r+0.1;
tmp=returnB(s,r);
}
tmp=0;
k=r-0.1;
while(tmp<B)
{
k=k+0.01;
tmp=returnB(s,k);
}
return k;
}
int returns()
{
float B,a;
int i=0;
float tmp4=1;
printf("B=");
scanf("%f",&B);
printf("a=");
scanf("%f",&a);
while(tmp4>B)
{
i++;
tmp4=returnB(i,a);
}
return i;
}
main()
{
float a,B,tmp,tmp1,tmp2;
int s,i,j,t,r;
tmp=0;
i=0;
printf("shu ru t");
scanf("%d",&t);
switch(t)
{
case 1:printf("shuru a");
scanf("%f",&a);
printf("shuru s");
scanf("%d",&s);
printf("\n%f",returnB(s,a));break;
case 2:printf("\n%f",returna());break;
case 3:printf("\n%d",returns());break;
case 4:exit(0);
default:printf("sdfdsffds");
}
/*while(1)
{
printf("1:输入a s,2:输入a,B,3:输入s,B");
scanf("%d",&t);
if(t==1)
{
scanf("a=%f,s=%d",&a,&s);
for(r=0;r<=s-1;r++)
tmp=power(a,r)+tmp;
tmp1=jiecheng(s);
tmp2=power(a,s)/tmp1;
B=tmp2/tmp;
printf("B=%f",B);
}
else if(t==2)
{
scanf("a=%f,B=%f",&a,&B);
}
else if(t==3)
{
scanf("s=%f,B=%f",&s,&B);
}
else if(t==4)exit;
else
printf("输入有错误,请重新输入:");
}*/
}
这是一个用C写的你要是有,你看看吧!!