hyqd.net
当前位置:首页 >> C语言编写直角三角形面积 >>

C语言编写直角三角形面积

#include <stdio.h>#include <stdlib.h> int main() { float a=0.0,b=0.0,s=0.0; printf("输入三角形直角边a="); scanf("%f",&a); printf("输入三角形直角边b="); scanf("%f",&b); s=(a*b)/2;//计算三角形面积 printf("三角形面积s=%f\n",s); return 0; }

好多错误,直接给你改正吧,你细细对照下看哪里错了:void main (){ float length1; float length2; float length3; float area; printf("请以此输入两个直角边长和斜边长\n");//scanf里面不要有'\n' scanf("%f%f%f",&amp;length1,&amp;length2,&

个数,只可能是底和高吧;/底和高 float Space; printf("please input Side and its Height;%f&quot,Height;/ Space = Side*Height/2; printf("the space is %; scanf("%f";);,&Height); void main() { float Side,&Side); scanf(",Space):\n&quot.2f\n&quot. #include

程序代码如下:#include <stdio.h>#include <math.h> int main() { printf("输入三个边长:\n"); float a,b,c; float s,area; scanf("%f%f%f",&a,&b,&c); s = (a+b+c)/2; area = sqrt(s*(s-a)*(s-b)*(s-c)); if(a+b>c && b+c>a && a+c>b) printf("面积是%.2

#include#includepublic void main(){ double a,b,c; scanf("%lf%lf%lf",&a,&b,&c); double area,preimeter; preimeter=a+b+c; double p=preimeter/2; area=sqrt(p*(p-a)*(p-b)*(p-c)); printf("area = %.2lf, preimeter = %.2lf\n",area,preimeter); getchar(); getchar();}

Then Somebody's dream had come true now./* 根据输入的三角形的三边,判断是否能组成三角形,若可以则输出它的面积和类型 (等腰,等边,直角,普通).按要求写程序.要求用简单的C语言写!!!*/#include<stdio.h>#include<math.h>

#include<stdio.h>int main(){ float a,b,c,t,s; printf("请输入3条边长:"); scanf("%f%f%f",&a,&b,&c); if(a>b){t=a;a=b;b=t;} if(b>c){t=b;b=c;c=t;} if(c>=a+b) { printf("不能构成三角形!\n"); return 0; } if(c*c==a*a+b*b) s=a*b/2; printf("直角三角形面积=%f\n",s); return 0;}

"stido.h"void main(){ int a,b,c; float sum=0.0 printf("输入直角三解形的两边:"); scanf("a=%d,b=%3d",&a,&b); printf("\n直角三角形的面积为:%f",sum(a,b));sum(int c ,int d){ sum=(1/2)*c*d;}

#include<stdio.h>#include<math.h> void main() { float a,b,c,s,area; scanf("%f,%f,%f",&a,&b,&c); s=1.0/2*(a+b+c); area=sqrt(s*(s-a)*(s-b)*(s-c)); printf("area=%7.2f\n",area); }

知道三边,利用海伦公式求面积.#include #include int main() { double a, b, c, p; scanf("%lf%lf%lf", &a, &b, &c); p = (a+b+c)/2; printf("%.3f", sqrt(p*(p-a)*(p-b)*(p-c))); //海伦公式,打印时%.3f保留小数点后三位 }

网站首页 | 网站地图
All rights reserved Powered by www.hyqd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com