c05ex11.py

2018-03-30  本文已影响0人  特丽斯纳普
# c05ex11.py
# Chaos program to print formatted side-by-side values

def main():
    print("This program illustrates a chaotic function")
    x1 = float(input("Enter the first seed between 0 and 1: "))
    x2 = float(input("Enter the second seed between 0 and 1: "))
    print()
    print("index     ", x1, "       ", x2)
    print("-------------------------------")
    for i in range(1, 11):
        x1 = 3.9 * x1 * (1 - x1)
        x2 = 3.9 * x2 * (1 - x2)
        print("{0:2} {1:15.6f} {2:10.6f}".format(i, x1, x2))

main()
上一篇下一篇

猜你喜欢

热点阅读