题解 1035: [编程入门]自定义函数之字符类型统计

来看看其他人写的题解吧!要先自己动手做才会有提高哦! 
返回题目 | 我来写题解

筛选

字符串函数搞定

解题思路:用字符串函数就可以注意事项:别把字符串变量名定义成str参考代码:defjudge(str1,b,a,c,d):foriinstr1:ifi.isdigit():a+=1elifi.isalpha():b+=1elifi.isspace():c+=1else:d+=1print(b,

一行代码解决(燃尽了)

摘要:解题思路: 通过 lambda 函数处理输入字符串:先用海象运算符分别统计字母 (a)、数字 (b)、空格 (c) 的数量,其他字符数由总长度减去 a、b、c 之和得到;再用 f-stri……

1035 字符类型统计

解题思路:#include#includeintletters=0,digits=0,spaces=0,others=0;voidcountchars(constchar*str){for(inti=0;str[i]!='\0';i++){if(is