#11436: c++ AC 要用long double


TzuchunChen (陳子濬)

學校 : 國立嘉義高級中學
編號 : 59216
來源 : [49.215.236.123]
最後登入時間 :
2019-05-06 08:46:33
b578. 一個角 -- 嘉義高中104資料學科能力競賽 | From: [27.105.43.227] | 發表日期 : 2016-10-13 21:45

#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 (王彬宇)

學校 : 義守大學
編號 : 72563
來源 : [111.254.36.83]
最後登入時間 :
2022-03-31 11:43:35
b578. 一個角 -- 嘉義高中104資料學科能力競賽 | From: [1.173.65.144] | 發表日期 : 2018-07-19 22:04

#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)

學校 : 桃園市私立復旦高級中學
編號 : 69322
來源 : [123.195.59.129]
最後登入時間 :
2024-05-13 21:37:35
b578. 一個角 -- 嘉義高中104資料學科能力競賽 | From: [36.228.102.156] | 發表日期 : 2018-07-19 22:31

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

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


 
ZeroJudge Forum