数学排列组合计算
实现下述目的:0.9*0.8**0.7*0.6*0.5*0.4*0.3*0.2*0.1
0.9*0.8*0.7*0.6*0.5*0.4*0.3*0.2*0.9
0.9*0.8*0.7*0.6*0.5*0.4*0.3*0.8^2
0.9*0.8*0.7*0.6*0.5*0.4*0.7^3
0.9*0.8*0.7*0.6*0.5*0.6^4
0.9*0.8*0.7*0.6*0.5^5
0.9*0.8*0.7*0.4^6
0.9*0.8*0.3^7
0.9*0.2^8
0.1^9
这是我个人编的程序,但总是不对。
#include <math.h>
#include"string.h"
#include"stdlib.h"
#include <stdio.h>
FILE *out;
int main(void)
{
long double m,n,c=1,k=10,h=k-10,sum=0,b,t,u,v,s=10; //k为实际的孔数
out=fopen("E:\\收获1.txt","wt");
for(m=1;m<=10;m++) //m为微滴进入的孔数
{
u=m/k;
v=k-h-m;
b=pow(u,v);
for(n=k;n>=k+1-m;n--)
c*=(n/s);
t=b*c;
sum=sum+t;
fprintf(out,"%.12f\n",t); //%.6f意思是保留6位小数
}
fprintf(out,"%.20f\n",sum);
}
[此贴子已经被作者于2016-4-20 21:14编辑过]