第三章第十题

来源:互联网 发布:用java搭建app服务器 编辑:程序博客网 时间:2024/05/20 09:07


#include<iostream>
#include <math.h>
using namespace std;
int main()
{
   int a, b, c;
   int p;
   float s;
   printf("请输入三边:");
   scanf("%d%d%d",&a,&b,&c);
    while(1){

        if(a+b>c && a+c>b && b+c>a)
  {

            break;

        }

       else
    {
     printf("不能构成三角形,请重新输入三边:");
          scanf("%d%d%d",&a,&b,&c);
    }

    }

    p = (a+b+c)/2;

    s = sqrt(p*(p-a)*(p-b)*(p-c));
     printf("%f\n",s);
    return 0;

}


0 0
原创粉丝点击