#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
long double n,a,b,c;
cin>>n;
while(n--)
{
cin>>a>>b>>c;
if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)
{
cout << "right triangle" <<endl;
}
else if(a*a<b*b+c*c&&b*b<a*a+c*c&&c*c<a*a+b*b)
{
cout << "acute triangle" <<endl;
}
else
{
cout << "obtuse triangle"<<endl;
}
}
return 0;
}
#include
#include
#include
#include
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
long double n,a,b,c;
cin>>n;
while(n--)
{
cin>>a>>b>>c;
if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)
{
cout << "right triangle" <<endl;
}
else if(a*a<b*b+c*c&&b*b<a*a+c*c&&c*c<a*a+b*b)
{
cout << "acute triangle" <<endl;
}
else
{
cout << "obtuse triangle"<<endl;
}
}
return 0;
}
為甚麼要用double,題目不是說正整數嗎?
#include
#include
#include
#include
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
long double n,a,b,c;
cin>>n;
while(n--)
{
cin>>a>>b>>c;
if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)
{
cout << "right triangle" <<endl;
}
else if(a*a<b*b+c*c&&b*b<a*a+c*c&&c*c<a*a+b*b)
{
cout << "acute triangle" <<endl;
}
else
{
cout << "obtuse triangle"<<endl;
}
}
return 0;
}
真的ㄟ!!!!!為什麼????求解