1.以简单的循环分支实现字符统计 str1 = input("输入字符串:") num=0;word=0;space=0;other=0; for i in str1: if i.isdigit(): num+=1 elif i.isalpha(): word+=1 elif i.isspace(): space+=1 else: other+=1 str2='''这段字符有%d个数字,有%d的字母,有%d个空格,其他字符有%d个'''%(num,word,space,other) p
"""输入一串字符,检查是否可以组成friend""" from collections import Counter def foo(num_list): for i in friend: try: num = count[i] if num < num_list[0]: num_list.pop() num_list.append(num) except KeyError as e: print('输入的字符串不能组成friend...
统计元音 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 58391 Accepted Submission(s): 23254 Problem Description 统计每个元音字母在字符串中出现的次数. Input 输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串. Output 对
1042 字符统计(20)(20 分) 请编写程序,找出一段给定文字中出现最频繁的那个英文字母. 输入格式: 输入在一行中给出一个长度不超过1000的字符串.字符串由ASCII码表中任意可见字符及空格组成,至少包含1个英文字母,以回车结束(回车不算在内). 输出格式: 在一行中输出出现频率最高的那个英文字母及其出现次数,其间以空格分隔.如果有并列,则输出按字母序最小的那个字母.统计时不区分大小写,输出小写字母. 输入样例: This is a simple TEST. There ARE num