Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
32 lines (27 loc) · 798 Bytes

File metadata and controls

32 lines (27 loc) · 798 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding:utf-8 -*-
__author__ = 'gjw'
__time__ = '2018/1/8 0008 下午 3:38'
# 题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。
# 程序分析:学会分解出每一位数。
x = input("请输入一个不多于五位数的整数")
ix = int(x)
a = int(ix/10000)
b = int(ix % 10000/1000)
c = int(ix % 1000/100)
d = int(ix % 100/10)
e = int(ix % 10)
if a != 0:
print("五位数:", e, d, c, b, a)
elif b != 0:
print("四位数:", e, d, c, b, )
elif c != 0:
print("三位数:", e, d, c)
elif d != 0:
print("两位数:", e, d)
else:
print("一位数:", e)
# 列表方式
print("我是进阶版")
print(str(len(x))+"位数:", end="")
for i in range(len(x)-1, -1, -1):
print(x[i], end=" ")
Morty Proxy This is a proxified and sanitized view of the page, visit original site.