#coding:utf-8import randomwhile True: xuanze=int(input("請輸入您想進入的題目:\n1、水仙花數\n2、百錢百雞\n4、退出\n(請輸入您的數字)")) if xuanze == 1: print("水仙花數") while True: whil ...
#coding:utf-8
import random
while True:
xuanze=int(input("請輸入您想進入的題目:\n1、水仙花數\n2、百錢百雞\n4、退出\n(請輸入您的數字)"))
if xuanze == 1:
print("水仙花數")
while True:
while True:
n=int(input("請輸入一個三位數"))
if n>100 and n<999:
break
else:
print("您輸入的數字不是三位數,請再次輸入")
print("輸入成功\n下麵數位分離")
n_gewei=int(n%10)
n_baiwei=int(n/100)
n_shiwei=int(n_baiwei%10)
print("百位:"+str(n_baiwei)+"\n十位:"+str(n_shiwei)+"\n個位:"+str(n_gewei))
jisuan=n_gewei^3+n_shiwei^3+n_baiwei^3
if jisuan==n:
print(str(n)+"這個數是水仙花數")
else:
print(str(n)+"這個數不是水仙花數")
tuichu=int(input("請問是否想退出:\n1、退出\n2、繼續\n(輸入數字):"))
if tuichu==1:
break
if tuichu==2:
continue
if xuanze == 2:
while True:
print("百錢百雞\n價格:\n公雞:5元/只\n母雞:3元/只\n小雞:1元/只\n用n元買")
n_money=int(input("請輸入您的零錢:"))
for i in range(int(n_money/5)):
for j in range(int(n_money/3)):
for k in range(int(n_money/1)):
if 5*i + 3*j + 1*k ==n_money:
print("公雞:"+str(i)+"母雞"+str(j)+"小雞"+str(k))
tuichu_1=int(input("請問是否想退出:\n1、退出\n2、繼續\n(輸入數字):"))
if tuichu_1 == 1:
break
if tuichu_1 == 2:
continue
if xuanze == 4:
break