(1)编写函数triangle,参数为三条边长,函数值为三角形的面积。
2条回答 默认 最新
handsomeman6 2021-12-20 08:53关注#include<stdio.h> #include<math.h> float triangle(int x,int y,int z); int main() {int x,y,z; scanf("%d %d %d",&x,&y,&z); printf("%f",triangle(x,y,z)); } float triangle(int x,int y,int z) {float s,S; s=(x+y+z)/2; if(x+y<z||x+z<y||y+z<x) printf("不能构成三角形"); else S=sqrt(s*(s-x)*(s-y)*(s-z)); return S; }有用请采纳,谢谢。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报