题解 | #求int型正整数在内存中存储时1的个数#
求int型正整数在内存中存储时1的个数
https://www.nowcoder.com/practice/440f16e490a0404786865e99c6ad91c9
import java.util.Scanner fun main(args: Array<String>) { val read = Scanner(System.`in`) var res = read.nextLine().toInt() var count = 0 for (i in 0 until 32) { if (res and 1 == 1) { count++ } res = res ushr 1 } print(count) }