當前位置:編程學習大全網 - 編程軟體 - C++初學者,求教~謝謝各位大神~用海倫公式計算三角形面積的編程

C++初學者,求教~謝謝各位大神~用海倫公式計算三角形面積的編程

#include <iostream.h>

#include <math.h> //使用根號函數要用這個頭文件

void main()

{

double a;

double b;

double c;

double p;

cout<<"please input a number as one of the lines"<<endl;

cin>>a;

cout<<"please input another one"<<endl;

cin>>b;

cout<<"the last one is required to be larger than "<<b-a<<" smaller than "<<a+b<<endl;

cin>>c;

p=0.5*(a+b+c);

double res=sqrt(p*(p-a)*(p-b)*(p-c)); //註意,要開根號的...

cout<<"square is "<<res<<endl;

}

  • 上一篇:為什麽和平精英這麽好玩?為什麽和平精英這麽好玩?
  • 下一篇:編程語言學第壹專業是什麽?
  • copyright 2024編程學習大全網