Python数据结构实例

实验一    rational 类的实现

实验目的:加深对理解

实验内容:rational 类的实现

参考程序:

# Module rational defines a class (a type) retional.

# More operations (methods) should be filled.

def gcd(m, n):

    if n == 0 :

        m, n = n, m

    while m != 0 :

        m, n = n%m, m

    return n

class rational :

    def __init__(self, num, den = 1) :

猜你喜欢

转载自blog.csdn.net/qq_44762986/article/details/104580793