令邊長為a,
一塊斜線的面積為x,
一塊點狀的面積為y,
一塊格子狀的面積為z。
則首先
正方形的面積減去四分之一以a為半徑的圓的面積
= a*a - a*a*π/4 = y+2*z ->(1)
再來六分之一以a為半徑的圓的面積減去以a為邊長的正三角形(想想看在哪裡...)
= a*a*π/6 - a*a*sqrt(3.0)/4 = 假設為某個面積w(想想看在哪裡...) ->(2)
接著把四分之一以a為半徑的圓的面積減去六分之一以a為半徑的圓的面積
= a*a*π/4 - a*a*π/6 = y+z+w ->(3)
則z=(y+2*z)-(y+z+w)+w=(1)-(3)+(2)就出來了,
那麼y=(y+2*z)-(2*z)=(1)-2*z也出來了,
而x=a*a-4*y-4*z也跟著出來了!
[C](0.056)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
#define PI 2.0*acos(0.0) | |
int main() | |
{ | |
double a; | |
while( scanf( "%lf", &a ) != EOF ) | |
{ | |
double x, y, z; | |
z = a*a - a*a*PI/4; | |
z -= a*a*PI/4 - a*a*PI/6 - ( a*a*PI/6 - a*a*sqrt(3.0)/4 ); | |
y = a*a - a*a*PI/4 - 2*z; | |
x = a*a - 4*y - 4*z; | |
printf( "%.3lf %.3lf %.3lf\n", x, 4*y ,4*z ); | |
} | |
return 0; | |
} |
0 意見:
張貼留言