题意 :把硬币往棋盘上扔,分别求出硬币占1,2,3,4个格子的时候的概率。
思路 : 求出公式输出,不过要注意输出格式,我还因为输入的时候用了int类型错了好几次。。。。。
//
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#define PI acos(-1.0) using namespace std ; int main()
{
int k;
double a1,a2,a3,a4,sum;
double c,m,n,t;
scanf("%d",&k) ;
for(int i = ; i <= k ; i++){
scanf("%lf %lf %lf %lf",&m,&n,&t,&c) ;
sum = m*n*t*t;
a1 = (t-c)*(t-c)*n*m+(c*(t-c)+c*c/4.0)*+c*(t-c)*(n+m-) ;
a2 = (m-)*n*t*c+(n-)*m*t*c-*(m-)*(n-)*c*c;
a3 = (m-)*(n-)*c*c*(-PI/);
a4 = (m-)*(n-)*c*c*PI/;
printf("Case %d:\n",i);
printf("Probability of covering 1 tile = %.4f%%\n",*a1/sum);
printf("Probability of covering 2 tiles = %.4f%%\n",*a2/sum);
printf("Probability of covering 3 tiles = %.4f%%\n",*a3/sum);
printf("Probability of covering 4 tiles = %.4f%%\n",*a4/sum);
printf("\n");
}
return ;
}