輸入三角形的三邊長,可判斷是否可構成三角形,若是,可得三角形面積…
執行檔: https://drive.google.com/file/d/0B03tzGyNUd6RdFZCUDZKUVZ2Qk0/view?usp=sharing
程式碼:
執行檔: https://drive.google.com/file/d/0B03tzGyNUd6RdFZCUDZKUVZ2Qk0/view?usp=sharing
程式碼:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define area(s,a,b,c) (double)s*(s-a)*(s-b)*(s-c)
int main(int argc, char** argv)
{
float a,b,c;
printf(" Please input the sides of the triangle ==>");
scanf("%f %f %f",&a,&b,&c);
if((area(0.5*(a+b+c),a,b,c))<=0)
printf("It is not a triangle\n");
else
printf("Area of triangle = %f\n",pow(area(0.5*(a+b+c),a,b,c),0.5));
system("pause");
return 0;
}
沒有留言:
張貼留言