编写一个三角形类计算三角形面积
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 16:10:43
如果是pascal和VB我知道怎么做但c语言我不会,这里就讲一下思路首先输入三个数(定位为实数),然后判断a+b>c且a+c>b且b+c>a,成立的话进行计算p=(a+b+c)/2s=sqrt(平方根
运用海伦公式dimPaslong,Saslongifa+b>cthenifb+c>athenifa+c>bthenp=(a+b+c)/2S=sqr(p*(p-a)*(p-b)*(p-c))endife
#includeclassangle{private:floatx,y,z;public:angle();voidthreeb(floata,floatb,floatc);friendvoidcoma
输入三角形三边长,求三角形面积.#include“math.h”main(){floata,b,c,s,area;scanf(“%f,%f,%f”,&a,&b,&c);s=1.0/2*(a+b+c);
#include <stdio.h>#include <math.h>//double sin(double x);#define&nb
图形抽象类的代码:abstractclassMyShape{abstractintcalGirth();//求周长abstractdoublecalSquare();//求面积}三角形类的实现:pub
publicclassTest{publicstaticvoidmain(String[]args){System.out.println("圆的面积:"+area(2));System.out.pr
A=[1,2];B=[6,2];C=[3,7];AB=B-A;AC=C-A;M=[AB;AC];S=1/2*det(M);%求出三角形的面积%%第二个问题首先新建一个M函数文件,里面内容如下funct
classTriangle{private:\x05doublea;\x05doubleb;\x05doublec;public:\x05Triangle():a(0),b(0),c(0){}\x05
#include#includemain(){inta,b,c,flag;floatarea,s;printf("inputsideoftriangle:");scanf("%d%d%d",&a,&b
classSharp{publicvirtualSun(){}}classSharp_Par1:Sharp{publicPointP1,P2,P2;publicoveridesSun(){}}再问:完
#include#include#includeusingnamespacestd;classbase{public:virtualvoiddisp()=0;};classtriangle:publi
function [ s ] = solve_area( a,b,c ) p=(a+b+c)./2;&nbs
假设知道三角形的三边长为a,b,c.程序如下:#include#includedoublearea(doublea,doubleb,doublec){doublearea=0,s=0;s=(a+b+c
错误提示是什么?此句应该为scanf("%d,%d",&a,&h);
#includemain(){floata,b,c;floatp,s;scanf("%f%f%f",&a,&b,&c);p=(a+b+c)/2;s=sqrt(p*(p-a)*(p-c)*(p-b));
voids(folata,folatb,folatc){folatp;p=(a+b+c)/2;S=√[p(p-a)(p-b)(p-c)];returns;}
#include#include#definePI3.14159usingnamespacestd;classShape{public:virtualdoublegetArea()=0;protect
//使用海伦公式#include/*ForIO*/#include/*Forsqrt()*/intmain(void){doublea,b,c,p,s;printf("请输入a,b和c:");scan
#include#includeusingnamespacestd;classSanJiaoXing{private:doublea,b,c;public:doubleArea();SanJiaoXi