From 5758c426016b9d0f3c571ec84b9194f7c3121ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=80=9D=E8=BE=B0?= Date: Tue, 23 Nov 2021 16:17:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'sy5-13.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sy5-13.py | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 sy5-13.py diff --git a/sy5-13.py b/sy5-13.py deleted file mode 100644 index 401420a..0000000 --- a/sy5-13.py +++ /dev/null @@ -1,35 +0,0 @@ -def isRose(n):#判断n是否是四位玫瑰数,是返回True,不是返回False - cnt=0 - for i in range(0,4): - temp=int(str(n)[i]) - cnt+=pow(temp,4) - return cnt==n; - -def checkNumber(n):#检查字符串n是不是构成4位数,是返回整数n,不是返回-1 - if(len(str(n))==4 and str(n).isnumeric):return int(n) - else: return -1 -def printRose(a,b):#输出区间【a,b】之间所有的四位玫瑰数,不存在输出提示信息 - n=0 - for num in range(a,b+1): - if isRose(num): - print(num) - n=n+1 - if n==0: - print("此区间没有四位玫瑰数") - -def main(): - a=checkNumber(input()) - if a==-1: - print("第一个数不是四位数") - return - b=checkNumber(input()) - if b==-1: - print("第二个数不是四位数") - return - if a<=b: - printRose(a,b) - else: - print(f'a>b,区间内没有四位玫瑰数!') - - -main()