正文

通过三角形三边求面积2006-02-03 20:01:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/aaawn/9954.html

分享到:

#include<math.h>#include<stdio.h>main(){ float a,b,c,s=0; double area=0; int flag=1, q;  do  { while(flag) {  printf("input the datas:\n");        scanf("%f%f%f",&a,&b,&c);     if(a+b<=c||a+c<=b||b+c<=a)  {      flag=1;      printf("the datas you input can't conbine a triangle;please input other datas.\n");  }  else   flag=0;  }        s=(a+b+c)/2;  printf("%f\n",s);  area=sqrt(s*(s-a)*(s-b)*(s-c));  printf("%5.3f",area);  printf("continue or not?\n1---yes;\n0---no;\n");     scanf("%d",&q);      if(q==1)    flag=1;     }while(flag);}

阅读(5821) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册