zoukankan      html  css  js  c++  java
  • triangle

    # -*-  coding:utf-8 -*-
    # Author:zhang
    class triangle(object):
    '''
    判断是否是三角形并判断出是什么三角形
    '''

    def __init__(self, x, y, z):
    '''定义三个边'''
    self.x = x
    self.y = y
    self.z = z

    def three(self):
    '''三角形判断'''
    if self.x <= 0 or self.y <= 0 or self.z <= 0:
    print "不是三角形"
    else:
    print "这三个数可能组成一个三角形"
    if (self.x + self.y) > self.z and (self.y + self.z) > self.x and (self.z + self.x) > self.y:
    print "这个真的是三角形呀"
    if self.x != self.y and self.x != self.z and self.y != self.z:
    print("这个是不等边三角形")
    if self.x ** 2 == self.y ** 2 + self.z ** 2 or self.y ** 2 == self.x ** 2 + self.z ** 2 or self.z ** 2 == self.x ** 2 + self.y ** 2:
    print "这个是直角三角形"
    if (self.x==self.y and self.x!=self.z) or (self.x==self.z and self.x!=self.y) or (self.z==self.y and self.x!=self.z):
    print "等腰直角三角形"
    elif self.x == self.y or self.y == self.z or self.z == self.x:
    print "这个可能是等边三角形也可能是等腰三角形"
    if self.x == self.y == self.z:
    print "这个是等边三角形"
    else:
    print "失败了,这个不是三角形"
    if __name__ == '__main__':
    aa = triangle(0, 6, 6)
    aa.three()

  • 相关阅读:
    二叉堆(最小堆, 最大堆)介绍与实现
    C++ 用变量定义数组
    C++ 用变量定义数组
    053185
    053184
    053183
    053182
    053181
    053180
    oracle prior
  • 原文地址:https://www.cnblogs.com/x2x3/p/8727817.html
Copyright © 2011-2022 走看看