# include <stdio.h>
# include <stdlib.h>
# include <math.h>
int judgeTriangle(int a, int b, int c);
int main(void)
{
int a, b, c;
int judge;
printf("请输入三个正整数\n");
scanf("%d %d %d", &a, &b, &c);
judge = judgeTriangle(a, b, c);
switch(judge)
{
case -1:
printf("它不能构成一个三角形,\n");
break;
case 0:
printf("它是一个不规则三角形。\n");
break;
case 1:
printf("它是一个直角三角形。\n");
break;
case 2:
printf("它是一个等腰三角形。\n");
break;
case 3:
printf("它是一个等边三角形。\n");
break;
}
system("pause");
return 0;
}
int judgeTriangle(int a, int b, int c)
{
int judge;
if((fabs(a - b) < c) && (fabs(a + b) > c))
{
if((a*a+b*b == c*c) || (a*a+c*c == b*b) || (b*b+c*c == a*a))
judge = 1;
else if(a!=b && b!=c && c!=a)
judge = 0;
else if(a == b || b == c || c == a)
{
if(a == b && b ==c && c == a)
judge = 3;
else
judge = 2;
}
}
else
judge = -1;
return judge;
}
代码没问题,这只是一个简单的判断三角形类型的程序,其他有汉字的程序都出现这个问题