写了一段程序,注释没写太多。可以参考一下。粘到这了哈~// File: main.h / main.h Created on: 2012-2-6 Author: Administrator / ifndef MAIN_H_define MAIN_H_include "stdio.h"//declare the function void initialTriangle(int* x, int* y, int* z);int check(int x, int y, ...
以下是一个用C语言编写的程序,输入三角形的三边长,计算并输出三角形的面积:include <stdio.h>#include <math.h>int main() {double a, b, c, s, area;printf("请输入三角形的三边长:\n");scanf("%lf %lf %lf", &a, &b, &c);s = (a + b + c) / 2.0;area = sqrt(s...
使用海伦公式 include <stdio.h>#include <math.h>int main(void){double a=3,b=4,c=6,p,s;p=(a+b+c)/2;s=sqrt(p*(p-a)*(p-b)*(p-c));printf("%.2lf\n",s);return 0;}
这个很简单,用海伦公式即可。include<stdio.h> include<math.h> int main(){ float a = 3, b = 4, c = 5;float l = (a + b + c) / 2;float s = 0;s = sqrt(l * (l - a) * (l - b) * (l - c));printf("The square is: %.2f\n", s);system("pause");}...
2).如果三条边相等,则程序输出为"等边三角形"。3).如果恰好有两条边相等,则程序输出为"等腰三角形"。4).如果三条边都不相等,则程序输出为"一般三角形"1测试内容输入为三角形的三条边,要求输入值为正整数,否则提示"输入不合法"要求三边长度都在20~80之间,否则提示"边长超出范围"如果...
include <stdio.h> include <math.h> void main(){ float a,b,c,p,s;printf("请输入三角形三边长:");scanf("%f%f%f",&a,&b,&c);p = (a+b+c)/2;s = sqrt(p*(p-a)*(p-b)*(p-c));printf("三角形面积为:%.1f\n",s);} include <stdio.h>//添加了判断三边能否...
海伦公式:S=√[p(p-a)(p-b)(p-c)]p=(a+b+c)/2代入即可。C语言:输入三角形三条边的边长,并输出面积:1、首先打开我们的DEV C++软件,点击“新建源代码”。2、在编辑页面输入以下代码:include<stdio.h> int main(){ folat a,b,c,s,p ;printf("请输入三角形的三边:");scanf(...
printf(" 2---计算矩形面积\n ");printf(" 3---计算三角形面积\n ");printf(" 4---终止程序执行\n ");printf(" 请输入选项值[1-4]: ");scanf("%d",&choice);cal(choice);}while(choice>=1&&choice<=3);} void cal(int n){ switch(n){ case 1: printf("圆面积:%.2f\n...
例如: 输入 4567 输出 22 8、编一程序,键盘输入整数A,B的值,然后打印A除以B的商的整数部分及余数。9、输入一个时、分、秒,把它转换为一个秒数。例如 输入 2 3 4 代表2小时3分钟4秒 输出 7384 代表一共有7384 秒 10、求三角形面积:给出三角形的三个边长为a,b,c,求三角形的...
include<stdio.h> include<math.h> int main(){ double a,b,c,p,area;printf("input lengths a b c\n");scanf("%lf %lf %lf",&a,&b,&c);p = (a+b+c)/2.0;area=p*(p-a)*(p-b)*(p-c);// 判断能否组成一个三角形, 能则输出面积,不能则打印信息。if (area < 0...