题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
import java.util.Scanner fun main(args: Array<String>) { val read = Scanner(System.`in`) while (read.hasNextLine()) { val a = read.nextLine() var digits = 0 var letters = 0 var others = 0 var spaces = 0 for (i in a) { if (i.isDigit()) { digits++ } else if (i.isLetter()) { letters++ } else if (i.isWhitespace()) { spaces++ } else { others++ } } println(letters) println(spaces) println(digits) println(others) } }#kotlin#