
#include<stdioh>
int main()
{
float a,b,c;
scanf("%f%f%f",&a,&b,&c);
if(a>0 && b>0 && c>0 && a+b>c && a+c>b && b+c>a)
{
if(a==b && b==c)
{
printf("等边三角形");
}
else if(a==b || a==c || b==c)
{
printf("等腰三角形");
}
else if(aa+bb==cc || aa+cc==bb || bb+cc==aa)
{
printf("直角三角形");
}
else
{
printf("普通三角形");
}
}
else
{
printf("非三角形");
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int s1,s2,s3;
cout<<"请输入三条边"<<endl;
cin>>s1>>s2>>s3;
if((s1+s2<=s3)||(s2+s3<=s1)||(s1+s3<=s2))
{
cout<<"不能构成三角形"<<endl;
return 0;
}
else
{
if(s1==s2&&s2==s3)
cout<<"是等边三角形"<<endl;
else if((s1==s2)||(s2==s3))
{
if((s1s1+s2s2==s3s3)||(s2s2+s3s3==s1s1)||(s1s1+s3s3==s2s2))
cout<<"是等腰直角三角形"<<endl;
else
cout<<"等腰三角形"<<endl;
}
else if((s1s1+s2s2==s3s3)||(s2s2+s3s3==s1s1)||(s1s1+s3s3==s2s2))
cout<<"直角三角形"<<endl;
else
cout<<"一般三角形"<<endl;
}
}
Dim
d(1
To
3)
As
Single,
a
As
Single,
b
As
Single,
c
As
Single
Private
Sub
Command1_Click()
d(1)
=
Val(Text1Text)
d(2)
=
Val(Text2Text)
d(3)
=
Val(Text3Text)
For
i
=
1
To
3
For
j
=
i
+
1
To
3
If
d(i)
<
d(j)
Then
t
=
d(i):
d(i)
=
d(j):
d(j)
=
t
Next
Next
a
=
d(1):
b
=
d(2):
c
=
d(3)
If
a
<
b
+
c
And
a
>
b
-
c
Then
"这三条线段能围成三角形"
If
a
^
2
=
b
^
2
+
c
^
2
Then
"这个三角形是直角三角形,它的面积是:"
&
b
c
/
2
Else
"这个三角形不是直角三角形"
End
If
Else
"这三条线段不能围成三角形"
End
If
End
Sub
#include<stdioh>
int tr(double a[])//判断是否能构成三角形
{
return (a[0]>=(a[1]+a[2]));
}
int zhijiao(double a[])//判断是否为直角三角形
{
if(a[0]a[0]==(a[1]a[1]+a[2]a[2]))return 1;
else return 0;
}
int deng(double a[])//判断是否为等腰、等边三角形
{
long n=0;
if(a[0]==a[1])n++;
if(a[0]==a[2])n++;
if(a[1]==a[2])n++;
return n;
}
int main()
{
double a[3],c,e;
printf("输入三条边的长度:");scanf("%lf %lf %lf",a,a+1,a+2);
if(a[1]>a[0]){c=a[1];a[1]=a[0];a[0]=c;}
if(a[2]>a[0]){c=a[2];a[2]=a[0];a[0]=c;}
if(tr(a)){printf("无法构成三角形\n");return 0;}
c=zhijiao(a);e=deng(a);
if(e==3)printf("该三角形为等边三角形\n");
else if(e&&c)printf("该三角形为等腰直角三角形\n");
else if(e)printf("该三角形为等腰三角形\n");
else if(c)printf("该三角形为直角三角形\n");
else printf("该三角形为一般三角形\n");
return 0;
}
#include <stdioh>
#include <mathh>
int main()
{float a,b,c,t;
scanf("%f%f%f",&a,&b,&c);
if(a>=b+c||b>=a+c||c>=a+b)
printf("不能构成三角形\n");
else
if(a==b&&b==c)
printf("等边三角形\n");
else
if(a==b||b==c||a==c)
printf("等腰三角形\n");
else
{if(a<b){t=a;a=b;b=t;}
if(a<c){t=a;a=c;c=t;}
if(fabs(aa-bb-cc)<1e-6)
printf("直角三角形\n");
else
printf("一般三角形\n");
}
return 0;
}
using System;
using SystemWindowsForms;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
var aStr = thistextBox1TextTrim();
var bStr = thistextBox2TextTrim();
var cStr = thistextBox3TextTrim();
//不为空
if (stringIsNullOrEmpty(aStr) && stringIsNullOrEmpty(bStr) && stringIsNullOrEmpty(cStr)) {
thislabel4Text = "A,B,C都不可以为空";
return;
}
//都是数字
float a, b, c;
if (!floatTryParse(aStr, out a)) {
thislabel4Text = "输入的A不是数字";
return;
}
if (!floatTryParse(bStr, out b)) {
thislabel4Text = "输入的B不是数字";
return;
}
if (!floatTryParse(cStr, out c)) {
thislabel4Text = "输入的C不是数字";
return;
}
//三遍从大到小排序 依次为a,b,c
if (a < b) {
float d = a;
a = b;
b = d;
}
if (a < c) {
float d = a;
a = c;
c = d;
}
if (b < c) {
float d = b;
b = c;
c = d;
}
//判断是否能构成三角形
if (!((a + b > c) && (a - b < c) && (b + c > a) && (b - c < a) && (a + c > b) && (a - c < b))) {
thislabel4Text = "此三边不能构成三角形";
return;
}
//判断是否等边
if (a == b&&b == c) {
thislabel4Text = "此三角形为等边三角形";
return;
}
//判断是否等腰
if (a == b || a == c || b == c) {
thislabel4Text = "此三角形为等腰三角形";
return;
}
thislabel4Text = "此三角形为不规则三角形";
}
}
}
bool triangle_or_not=true;\x0d\double p1_x,p2_x,p3_x,p1_y,p2_y,p3_y;\x0d\cin>>p1_x>>p1_y;\x0d\cin>>p2_x>>p2_y;\x0d\cin>>p3_x>>p3_y;\x0d\double long12=sqrt((p1_x-p2_x)(p1_x-p2_x)+(p1_y-p2_y)(p1_y-p2_y));\x0d\double long13=sqrt((p1_x-p3_x)(p1_x-p3_x)+(p1_y-p3_y)(p1_y-p3_y));\x0d\double long32=sqrt((p3_x-p2_x)(p3_x-p2_x)+(p3_y-p2_y)(p3_y-p2_y));\x0d\//求出三点之间的距离\x0d\if(long12+long13==long32)\x0d\{\x0d\triangle_or_not=false;\x0d\}\x0d\if(long12+long32==long13)\x0d\{\x0d\triangle_or_not=false;\x0d\}\x0d\if(long32+long13==long12)\x0d\{\x0d\triangle_or_not=false;\x0d\}\x0d\//判断三点是否在同一直线上\x0d\if(triangle_or_not==true)\x0d\{\x0d\double a=long12;\x0d\double b=long13;\x0d\double c=long32;\x0d\double p=(a+b+c)/2;\x0d\double area=sqrt(p(p-a)(p-b)(p-c));\x0d\cout回答于 2022-12-11
以上就是关于c语言判定三角形类型全部的内容,包括:c语言判定三角形类型、c++急急急急急急!!判断三角形类型(程序需要运用函数)、VB三角形判断程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)