编写一个求任意三角形面积的函数
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/13 20:02:13
intfun(intn){inta=n,b=0;while(a>0){b=b*10;b=b+a%10;a=a/10;}printf("%d",b);getch();return0;}或者把后三行删掉,
运用海伦公式dimPaslong,Saslongifa+b>cthenifb+c>athenifa+c>bthenp=(a+b+c)/2S=sqr(p*(p-a)*(p-b)*(p-c))endife
#include#includefloatarea(float,float,float);voidmain(){\x09floata,b,c,result;\x09printf("输入三角形的三边:\
#includeintsum(intn){ints=0;while(n){s+=n%10;n/=10;}returns;}intmain(void){ints=0;for(int
#include<stdio.h>int getmax(int a,int b){ re
PrivateFunctionSUM(Fir_LAsDouble,Fir_SAsDouble,Scend_LAsDouble,Scend_SAsDouble)AsDoubleSUM=Fir_L*Fir
#include#includemain{inta,b,c;intp,s;scanf("%d%d%d",&a,&b,&c);p=(a+b+c)/2;if(a+b>c&&a+c>b&&b+c>a){s=
#includeclassangle{private:floatx,y,z;public:angle();voidthreeb(floata,floatb,floatc);friendvoidcoma
includeincludeddoublefun(inta,intb,intc){intp;p=(a+b+c)/2;returnsqrt(p*(p-a)*(p-b)*(p-c));}再问:ok再问:
#include#includeusingnamespacestd;intmain(){floata;floatb;floatc;floats;floatp;coutb>>c;p=(a+b
#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
用海伦公式比较简单.不知道你要用什么语言编写?我简单写一下C语言的:doublesabc(doublea,doubleb,doublec){doublep,s;p=(a+b+c)/2;s=squrt(
p=1/4*(2*x*z+y*y-x*x-z*z);应该改为p=1.0/4*(2*x*z+y*y-x*x-z*z);或者p=1/4.0*(2*x*z+y*y-x*x-z*z);原因是:当进行运算时,1
chara;scanf("%c",&a);switch(a){case'y':圆形case'c':长方形cash'z':正方形}
voids(folata,folatb,folatc){folatp;p=(a+b+c)/2;S=√[p(p-a)(p-b)(p-c)];returns;}
//使用海伦公式#include/*ForIO*/#include/*Forsqrt()*/intmain(void){doublea,b,c,p,s;printf("请输入a,b和c:");scan
functionfun(d,h){if(d
利用海伦公式:S=(p(p-a)(p-b)(p-c))^(1/2);S为三角形面积,a,b,c为三角形三边长,p为三角形半周长(p=(a+b+c)*(1/2))(p(p-a)(p-b)(p-c))^(