Quick actions

cmd+k|ctrl+k

Navigation

Languages

Bài 6

Snippet info

Language

Python

Visibility

public

Author

mr2uang55

Created

2016-10-16T18:16:56Z

Updated

2016-10-16T18:16:56Z

#Khoi tao s truoc
s = 'asfdasfwefewfwfqwhifsadfsafcoijfocwogheqqciwhoqwqwocfqwirjwicjwfcjwoifcmqwofmqcwoeghwogocwogjfgdjgkdlgdmsvmvxsafdkaecjf'
min = 0
khoitaomin = False
maxchar =''
max = 0
minchar =''
"""
Thuat toan su dung vong lap for:
    buoc 1: su dung count de tinh xem cai nao lon nhat roi gan vao max cung voi max word
    buoc 2: min tuong tu voi max
"""
for word in s:
    count = s.count(word)
    if(khoitaomin == False):
        min = count
        khoitaomin = True
    if(count > max):
        max = count
        maxchar = word
    if(count < min):
        min = count
        minchar = word

print("Ky tu max: %c So luong: %d" % (maxchar,max))
print("KY tu min: %c So luong: %d" % (minchar,min))
INFO