#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a,b,c;
cin >> a >> b >> c;
if (a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){cout << "right triangle" << endl;}
else if (a*a+b*b>c*c&&a*a+c*c>b*b&&b*b+c*c>a*a){cout << "acute triangle" << endl;}
else {cout << "obtuse triangle" << endl;}
return EXIT_SUCCESS;
}
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
int a,b,c;
cin >> a >> b >> c;
if (a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){cout << "right triangle" << endl;}
else if (a*a+b*b>c*c&&a*a+c*c>b*b&&b*b+c*c>a*a){cout << "acute triangle" << endl;}
else {cout << "obtuse triangle" << endl;}
return EXIT_SUCCESS;
}
可以從他移動的步數去思考
這是我的程式碼
#include <iostream>
using namespace std;
int main()
{
int A , B , a , b;
while(cin>>A>>B>>a>>b)
{
if(A==0&&b==0&&B==0&&a==0)
break;
int mx= max(A ,a)-min(A ,a);
int my = max(B ,b)-min(B ,b);
if(mx==0&&my==0)
cout<<0<<endl;
else if(mx==0&&my!=0||mx!=0&&my==0||mx==my!=0)
cout<<1<<endl;
else
cout<<2<<endl;
}
return 0;
}