Python小练习- SDUT 2521 出现次数

View Code
 1 #!/usr/bin/env python 

 2 #coding=utf-8                                                                                      

 3 while True:                                                                                                

 4     n = input()                                                                                            

 5     max = 1                                                                                                

 6     num = 1                                                                                                

 7     a = []                                                                                                 

 8     '''for i in range(0,n):                                                                                  

 9         t = raw_input()                                                                                   

10         a.append(int(t))'''                                                                                       

11     a = [int (i) for i in raw_input().split()]                                                             

12     a.sort()                                                                                               

13     x = int(a[0])                                                                                          

14     for j in range(0,n-1):                                                                                 

15         if int(a[j]) == int(a[j+1]):                                                                       

16             num = num + 1                                                                                  

17         else:                                                                                              

18             num = 1                                                                                        

19         if num > max:                                                                                      

20             max = num                                                                                      

21             x = int(a[j])                                                                                  

22     print x,max     

题目很水 没什么好说的 就是学习一下输入输出

你可能感兴趣的:(python)