#11436: c++ AC 要用long double


TzuchunChen (陳子濬)


#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;
}

#14493: Re:c++ AC 要用long double


r0976439561@gmail.com (王彬宇)


#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,題目不是說正整數嗎?

#14494: Re:c++ AC 要用long double


fdhs107HandsomeKenny (Kenny Hsu)


#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;
}

真的ㄟ!!!!!為什麼????求解