生成全排列
n = 0
vis = [0 for i in range(100)]
ans = [0 for i in range(100)]
def work(cnt):
if cnt == n:
for i in range(n):
print(ans[i], end=' ')
print()
return
for i in range(1, n+1):
if vis[i]==0:
vis[i] = 1
ans[cnt] = i
work(cnt+1)
vis[i] = 0
n = int(input())
work(0)
统计不同单词个数
word = input()
word = word.strip('.')
word = word.split()
s = set()
for i in word:
s.add(i.upper())
print(len(s))
同分情况下的排名
n = int(input())
l = list(map(int, input().split()))
score = int(input())
l.sort()
cnt = 1
for i in range(len(l)):
if l[i] > score:
cnt += 1
print(cnt)
标签:cnt,word,vis,python,题集,int,range,input
From: https://www.cnblogs.com/zychh/p/16746940.html