Pagini recente » Cod sursa (job #1773366) | Cod sursa (job #275147) | Cod sursa (job #601029) | Cod sursa (job #1543253) | Cod sursa (job #276798)
Cod sursa(job #276798)
// dezstru.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
long n,k,val[30],cont=0;
float l,e[30],t=0;
void afisare()
{
float d=1;
for(int i=1;i<=k;i++)
d=d*e[val[i]];
cont ++;
t=t+d;
}
void back( int a )
{
if(a==k+1)
{
afisare();
return ;
}
for(int i=val[a-1]+1;i<=n;i++)
{
val[a]=i;
back(a+1);
}
}
int main()
{
int i;
freopen("dezastru.in","r",stdin);
freopen("dezastru.out","w",stdout);
scanf("%ld %ld",&n,&k);
for(i=1;i<=n;i++)
scanf("%f ",&e[i]);
back(1);
l=t/cont;
printf("%f",l);
return 0;
}