编写一个程序,根据用户输入的三角形的三条边长判定是何种三角形,对于有效三角形,求其面积。

作者&投稿:兀有闻 (若有异议请与网页底部的电邮联系)
编写一个程序根据用户输入的三角形的三边长判定是何种三角形~

你好,程序如下:

#include
void main()
{
double a,b,c;
printf("请输入三角形的三条边的长度:
");
scanf("%lf%lf%lf",&a,&b,&c);
if(a+b>c&&a+c>b&&b+c>a)
{
if(a==b&&b==c)
printf("等边三角形!
");
else
{
if((a==b&&b!=c)||(b==c&&b!=a)||(a==c&&c!=a))
printf("等腰三角形!
");
else
{
if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
printf("直角三角形!
");
}
}
}
else
{
printf("不能构成三角形!
");
}
}

有疑问提出
望采纳

Turbo 2.0 编译通过!

#include
#include
main()
{
float a,b,c;
/*printf("输入三角形的三条边a,b,c:"); */
printf("please input triangle side a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
/*
判断三边是否构成三角形
任意两条边的和大于另一条边,写程序时需做三次判断。
*/
if(a+b>c||a+c>b||b+c>a)
{
if(a==b&&a==c)
/*如果三条边均相等,则为等边三角形*/
/*printf("等边三角形
"); */
printf("equilateral triangle
");
else if(a==b||a==c||b==c) /*如果只有两条边相等,则只为等腰三角形*/
/*printf("等腰三角形
"); */
printf("isoceles triangle
");
else if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a) /*如果两边的平方和等于第三边平方,则为直角三角形*/
/*printf("直角三角形
"); */
printf("right-angled triangle
");
else
printf("triangle
");
}
else
printf("Can't make up of triangle!
");
}

你好,程序如下:

#include<stdio.h>
void
main()
{
double
a,b,c;
printf("请输入三角形的三条边的长度:\n");
scanf("%lf%lf%lf",&a,&b,&c);
if(a+b>c&&a+c>b&&b+c>a)
{
if(a==b&&b==c)
printf("等边三角形!\n");
else
{
if((a==b&&b!=c)||(b==c&&b!=a)||(a==c&&c!=a))
printf("等腰三角形!\n");
else
{
if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
printf("直角三角形!\n");
}
}
}
else
{
printf("不能构成三角形!\n");
}
}

有疑问提出
望采纳


C语言:写一个程序,判断某一年是否为闰年。 用函数的调用来写。
1、首先在VS中准备一个Console程序。2、然后获取当前时间。3、然后在Datetime类中有一个IsLeapYear方法用来判断闰年。4、IsLeapYear得到的是布尔类型的值。5、接着点击运行按钮,如下图所示。6、就可以看到当前的年是不是闰年了。

用C#写一个自增序号的程序,实现对序号的自动增加。
给你个例子参考下:public string GetAutoDocNo(){ string DocNo = "AD";string today = DateTime.Today.Date.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);DataSet DocDs = GetDataSet(" select * from News");\/\/初始化 if (DocDs.Tables[0].Rows.Count == 0){ DocNo += today ...

写一个程序,输入任何一个公民的月收入和五险一金,能够计算他应缴纳的...
假定5险一金固定是1000元,起征点是3500,程序如下:include <stdio.h> int main(int argc, char *argv[]){ float money,temp,total,t;printf("请输入工资收入:");scanf("%f",&money);t=money-3500-1000; \/\/ 全月收入总额-1000(五险一金)-3500(现阶段个税起征点)if (t<1500)temp...

用c++语言编写一个程序:如何在字符串里查找第一个不重...
include <iostream>using namespace std;void f(char* s){ int cnt,i,l; char* s1; l=strlen(s); for(i=0;i<l;i++) { s1=s; cnt=0; while(*s1) { if(*s1==s[i]) { cnt++; if (cnt>1) break; } s1++; } if(cnt==1) { cout...

编写一个程序,先输入一组学生成绩,用-1表示输入结束,然后输入某一区间值...
include<stdio.h> include<stdlib.h> define N 20 typedef struct Student { char name[10];int no; \/\/学号 int grade;\/\/成绩 }Student;void Input(Student *stud ,int n);int main(void){ int low, high;printf("请输入成绩区间low-high\\n");scanf("%d %d",&low,&high);Student stud...

用c语言写一个程序,设S=1*2*3*…*n,求S不大于400000时的最大n_百度知...
include<stdio.h> int main(){int n,s=1;for(n=1;s<=400000;)s*=++n;printf("最大的n是:%d",--n);return 0;}

用C语言编写一个复杂程序 急需
L = L +1 ;while ( A[R] >= pivot )R = R -1 ;} while ( L <= R );return L;} void quicksort( int i, int j ,int A[]){ int pivot ;int pivotindex , k;pivotindex = findpivot( i, j ,A); \/\/pivotindex可以就选第一个,可这是怎么判断结束呢,根据快排...

写一个将华氏温度转换成摄氏温度的程序,转换的公式是:°F = (9\/5...
程序公式如下:include<stdio.h>float change(float x);void main(){float fahr;printf("请输入摄氏温度:");scanf("%f",&fahr);printf("\\n对应的华氏温度为:%.1f\\n\\n",change(fahr));}float change(float x){float cent=x*9\/5+32;return cent;} ...

编一C语言程序,任意输入一个大写字母,将其转换成小写字母并输出_百度知 ...
因为是大写字母转化为小写字母;我们可以考虑运用ASCII码来解决这类问题。根据ASCII码,大写字母变为小写字母只需要+32即可.例如我们定义char ch1='B';我们仅需要输出ch1+32即可;下面写给出具体程序:首先定义一个字符变量;然后提醒输入大写字母;在输入大写字母后;由ASCII码转化后;输出的即为小写字母。

用JAVA写一个按钮程序,单击按钮按钮上的数字就自动加1,点一次加一次...
import javax.swing.*;import java.awt.event.*;public class UITest extends JFrame implements ActionListener{ JButton button;int count;UITest(){ count = 0;button = new JButton("有效按钮:"+count);button.addActionListener(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this...

长洲区19212389387: 编写一个程序根据用户输入的三角形的三边长判定是何种三角形 -
姬承利鲁: 你好,程序如下:void main(){double a,b,c; printf("请输入三角形的三条边的长度:\n"); scanf("%lf%lf%lf",&a,&b,&c);

长洲区19212389387: 编写C程序.实现根据用户输入的三角形的三条边长判定是何种三角形#include #includemain(){float a,b,c;printf("输入三角形的三条边a,b,c:");scanf("%f,%f,... -
姬承利鲁:[答案] Turbo 2.0 编译通过! #include #include main() { float a,b,c; /*printf("输入三角形的三条边a,b,c:"); */ printf("please input triangle side a,b,c:"); scanf("%f,%f,%f",&a,&b,&c); /* 判断三边是否构成三角形 任意两条边的和大于另一条边,写程序时...

长洲区19212389387: 入门c语言:编写程序.实现根据用户输入的三角形的边长,判定是何种三角形. -
姬承利鲁: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23#include <stdio.h> intmain(void) {inta,b,c;scanf("%d,%d,%d",&a,&b,&c);if(a+b<=c||a+c<=b||b+c<=a){printf("\n不能构成三角形:");}elseif((a==b||a==c||b==c)&&!(a==b&&b==...

长洲区19212389387: 编写C程序.实现根据用户输入的三角形的三条边长判定是何种三角形 -
姬承利鲁: #include int main(void) { int a,b,c; scanf("%d,%d,%d",&a,&b,&c); if (a+b printf("\n不能构成三角形:"); } else if((a==b||a==c||b==c)&&!(a==b&&b==c&&a==c)){ printf("\n等腰三角形:"); } else if(a==b&&b==c&&a==c){ printf("\n等边三角形...

长洲区19212389387: 用C语言编写一个程序,实现用户输入的三角形的三条边长判定是何种三角形?
姬承利鲁: #include<iostream.h> void main() {float a, b, c;for(cin>>a>>b>>c;a>0&&B>0&&c>0;){if(a+b<c||b+c<a) cout<<"不能构成三角形\n";else if(a==b&&b==c) cout<<"等边三角形\n";else if((a*a==b*b+c*c)||(b*b==a*a+c*c0||(c*c==a*a+b*b)) { if(...

长洲区19212389387: 1、编写一个程序根据输入的三角形的三条边判断是否能组成三角形,如果可以则输出它的面积和三角形类型. -
姬承利鲁: 1、 Private Sub Command1_Click() Dim a, b, c As Integera = Val(InputBox("边1")) b = Val(InputBox("边2")) c = Val(InputBox("边3"))If a + b > c And a + c > b And b + c > a Then Print "周长:" & a + b + cElse Print "不能构成三角形"...

长洲区19212389387: JAVA编程:根据用户输入的三角形的三个边长,判断三角形是不是直角三角形? -
姬承利鲁: package abc;import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List;public class Triangle {public static void main(String[] args) {double a=getSide();double b=...

长洲区19212389387: 编写一个程序,要求根据输入的三边判定三角形的类型并求面积 -
姬承利鲁: #include"stdio.h" #include"math.h" main() { float a,b,c,s,area; printf("a,b,c="); scanf("%f%f%f",&a,&b,&c); if(a+b>c&&b+c>a&&a+c>b) { s=(a+b+c)/2.0; area=sqrt(s*(s-a)*(s-b)*(s-c)); printf("area=%f\n",area); if(a==b&&b==c) printf("等...

长洲区19212389387: 编写一个程序,要求用户输入三角形的底边长和高,求算这个三角形的面积,并输出计算 -
姬承利鲁: a 和h也是实数型的才可以,如果你非要定义它们是整数型,那s 也是整数型

长洲区19212389387: 编写一个程序,输入三角形的三条边abc的长度,判断是否构成一个三角形,并输出结 -
姬承利鲁:[答案] 用什么语言? 主要是判断两边之和大于第三边,两边之差小于第三边,重点都在这了 C: #include "stdafx.h" #include using namespace std; int main() { int a ,b,c; cout

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网