求教,67分
查看原帖
求教,67分
737600
anchorage楼主2022/7/3 16:13
#include <iostream>

using namespace std;

int main() {
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    int flag=0;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3-i;j++)
        {
            if(a[j]==a[j+1]) flag=1;
            if(a[j]>a[j+1])
            {
                int temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    int cnt=0;
    if(a[1]+a[0]<=a[2])
    {
        cout<<"Not triangle";
        return 0;
    }
    else
    {
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]) cout<<"Right triangle",cnt++;
        else if(a[0]*a[0]+a[1]*a[1]<a[2]*a[2]) cout<<"Obtuse triangle",cnt++;
        else if(a[0]*a[0]+a[1]*a[1]>a[2]*a[2]) cout<<"Acute triangle",cnt++;
        if(cnt)
        {
            if(a[0]==a[1]&&a[1]==a[2]) cout<<"\nEquilateral triangle";
            else if(flag) cout<<"\nIsosceles triangle";
        }
        else
        {
            if(a[0]==a[1]&&a[1]==a[2]) cout<<"Equilateral triangle";
            else if(flag) cout<<"Isosceles triangle";
        }
        return 0;
    }
}

2022/7/3 16:13
加载中...