01/80 统计素数个数-暴力算法 March 28, 2024 0 - 算法, 0.2 - 80 道基础算法 本文总阅读量次 123456789101112131415161718192021222324fun isPrime(n: Int): Boolean { if (n <= 1) return false for (i in 2 until n) { if (n % i == 0) { return false } } return true}fun countPrimesInArray(arr: IntArray): Int { var count = 0 for (num in arr) { if (isPrime(num)) { count++ } } return count}fun main() { val arr = intArrayOf(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) println("Count of prime numbers in the array: ${countPrimesInArray(arr)}")} Newer 03/80 删除排序数组中的重复项 Older TextView layout_constrainedWidth 属性