#include<stdio.h>
int main(void)
{
int t,q;
float side1[30],side2[30],side3[30],maxmumside;
scanf("%d",&t);
for(q=0; q<t; q++)
{
scanf("%f %f %f",&side1[q],&side2[q],&side3[q]);
}
for(q=0; q<t; q++)
{
if(side1[q]==side2[q]==side3[q]){printf("Case %d: Equilateral\n",q+1); continue;}
if(side1[q]>side2[q]&&side1[q]>side3[q]){maxmumside=side1[q]; if(side2[q]+side3[q]<maxmumside){printf("Case %d: Invalid\n",q+1);continue;}}
if(side2[q]>side1[q]&&side2[q]>side3[q]){maxmumside=side2[q]; if(side1[q]+side3[q]<maxmumside){printf("Case %d: Invalid\n",q+1);continue;}}
if(side3[q]>side2[q]&&side3[q]>side1[q]){maxmumside=side3[q]; if(side2[q]+side1[q]<maxmumside){printf("Case %d: Invalid\n",q+1);continue;}}
if(side1[q]==side2[q] || side1[q]==side3[q] || side3[q]==side2[q]) {printf("Case %d: Isosceles\n",q+1);}
else{
if(side1[q]!=side2[q] && side1[q]!=side3[q] && side3[q]!=side2[q]) {printf("Case %d: Scalene\n",q+1);}}
}
return 0;
}
總是會把Scalene判斷成Isosceles
與正確輸出不相符(line:5)
您的答案為: Case 5: Isosceles
正確答案為: Case 5: Scalene
可是明明輸入資料是三邊不等長,那我的程式碼到底是怎麼把他判斷成有兩個一樣長的呢?= =?
而你所提的問題,在於第五筆測資2147483647 2 2147483646存進去float陣列後,變成了2147483648.0 2.0 2147483648.0,因此輸出才會出乎意料。