识别c中三角形的类型

  • 本文关键字:类型 三角形 识别 c
  • 更新时间 :
  • 英文 :


在这个项目中,我必须通过将三角形的边作为输入来识别三角形的类型。编译是可以的,但是结果与实际的数学不匹配。

#include <stdio.h>
int main()
{
int a , b , c;
int A,B,C;
A=a*a  ;
B=b*b ;
C=c*c ;
printf("Enter the biggest siden");
scanf("%d",&a);
printf("Enter the second siden");
scanf("%d",&b);
printf("Enter the third siden");
scanf("%d",&c);
if(A=B+C) printf("Right");
if(A<B+C) printf("OBTUSE");
else if(a<b+c)  printf("ACUTE");

return 0 ;
}

if语句有一个'='而不是'==',计算需要在scanf函数之后设置。代码:


#include <stdio.h>
int main()
{
int a, b, c;
int A, B, C;
printf("Enter the biggest siden");
scanf_s("%d", &a);
printf("Enter the second siden");
scanf_s("%d", &b);
printf("Enter the third siden");
scanf_s("%d", &c);
A = a * a;
B = b * b;
C = c * c;
if (A == (B + C)) printf("Right");
if (A < (B + C)) printf("OBTUSE");
else 
printf("ACUTE");

return 0;
}